Maybe this? You should add more info to the "Content-Type" header:
uploadRequest.contentType = "multipart/form-data; boundary=<<boundary here>>"; http://stackoverflow.com/questions/9559948/post-file-upload-using-urlrequest http://www.marstonstudio.com/2007/10/19/how-to-take-a-snapshot-of-a-flash-movie-and-automatically-upload-the-jpg-to-a-server-in-three-easy-steps/ On Mon, Mar 21, 2016 at 10:56 AM, OmPrakash Muppirala <[email protected]> wrote: > Do you have a steady wifi connection on your device? Is your server > available publicly? If so you can test with 3G/4G to see if works better? > > Thanks, > Om > On Mar 21, 2016 10:50 AM, "leokan23" <[email protected]> wrote: > > > Ok so i did a lot of trials with this and it looks like that the > URLRequest > > sometimes fails without a reason. > > > > my testing code is: > > > > protected function > galleryPhotoButton2_clickHandler(event:MouseEvent):void > > { > > imgFile = File.documentsDirectory; > > imgFile = > > imgFile.resolvePath("header_bg_old.jpg"); > > > > var urlRequest:URLRequest = new > > URLRequest("http://MY_DOMAIN/app/photo_upload/upload.php"); > > urlRequest.useCache = false; > > > > urlRequest.contentType="multipart/form-data"; > > > > imagelbl.text=imgFile.nativePath; > > trace(imgFile.url); > > image.source=imgFile.url; > > file = imgFile; > > > > if(!file.exists) > > { > > > > trace("File does not exist"); > > } > > file.addEventListener(Event.COMPLETE, > > uploadCompleteHandler); > > file.addEventListener(Event.OPEN, > > openUploadHandler); > > > > file.addEventListener(ProgressEvent.PROGRESS, onProgress); > > > > file.addEventListener(IOErrorEvent.IO_ERROR, uploadFailed); > > > > > > var variables:URLVariables = new > > URLVariables(); > > variables.folder=folder.text; > > > > urlRequest.method=URLRequestMethod.POST; > > urlRequest.data=variables; > > > > ping(); > > > > file.upload(urlRequest, "fileToUpload", > > false ); > > urlRequest = null; > > } > > > > > > I have writen a ping method (URLMonitor) to actually find out if the flex > > app get's the link. > > When trying this on a local server (XAMPP), it works everytime, > > When i try it on the live server, i have to wait for a while and it works > > 2-4 times out of 10. All the other times i get the error Error #2038: > File > > I/O Error. URL. I have tried in 3 different servers with the same > results. > > > > Not sure how to get over this. > > > > > > > > -- > > View this message in context: > > > http://apache-flex-users.2333346.n4.nabble.com/Flex-mobile-Upload-to-php-server-problem-tp12292p12312.html > > Sent from the Apache Flex Users mailing list archive at Nabble.com. > > >
