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);
}
精彩评论