Hi everyone, hope someone could help me.
Here's the issue:
I have an URL like this "http://site.com/imgsrc/getimage.php?id=JK2Q", and if I open that url in a browser... I get directly the download of an attached image, because the headers are Content-disposition: attachment (maybe default.jpg)
app.js
var url = "http://site.com/imgsrc/getimage.php?id=JK2Q" var myFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, imageDirName, url); // Create the HTTP client to download the asset. var xhr = Ti.Network.createHTTPClient(); xhr.onload = function() { Ti.API.info( this.getResponseHeader('Content-Length') ); // 10504 Ti.API.info( this.getResponseHeader('Content-Type') ); // image/jpg if (xhr.status == 200) { myFile.write(xhr.responseData); Ti.API.log(file.nativePath); // this shows .../iPhone%20Simulator/7.1/Applications/Documents/localimages/http://site.com/imgsrc/getimage.php }; }; // Issuing a request to the remote URL xhr.open('HEAD', url); // Finally, sending the request out. xhr.send();I'm trying to download that image file from the sample url but I'm getting the getimage.php file instead off default.jpg or whatever the file is.
I don't know what needs to be done. Please help!