开发者

validate file content before uploading

I want to upload a yaml file to a server. But before uploading to the server I need to check whether file content is correct format of yaml开发者_JS百科 syntax and datas inside the yaml. Is there any way to that?


If you intend to do this in a browser with pure javascript then, no, there is no way. For security reasons you don't have access to files on the client computer. This validation could be done on the server.


No. you can't do that. But still you can do something, some 30%-40% of cases will be covered.

function upload(upload_field)
{
var filename = upload_field.value;
var extension=substr(filename,-4,4);
    alert(extension);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜