check if image is valid before uploading— mootools

El Intocable

New Member
I'm using mootools request to push image data to a server to import images. My question is how to determine if an image path is valid before completing the request?Here's what I have now--http://jsfiddle.net/sTbFb/1/\[code\]function doUpload(){ var remoteFile = document.id('uploadRemote').get('value'); var imageRequest = new Request({ url:'index.php', method: 'post', data: 'path='+remoteFile, onRequest: function() { console.log(remoteFile); var myimage = Asset.image(remoteFile, { //onError: imageRequest.cancel() // <-- this doesn't work either onError: this.cancel() } ); }, onSuccess: function(response) { alert(response); } }).send();}document.id('submit').addEvent('click', function(){ doUpload();});\[/code\]I'm trying to use Asset.image to test if a path is truly an image-- then if it's not, to cancel the request. However, it's not working out.Any hints on what I'm doing wrong? Thanks!
 
Top