开发者

validate file content before uploading

开发者 https://www.devze.com 2023-03-01 15:28 出处:网络
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

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

精彩评论

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

关注公众号