File upload issue on Mac OSX
hi,
i facing problem uploading files on mac system. same code runs perfect on windows system. below snippet of code using:
public class browseimage extends movieclip { public var fr:filereference = new filereference(); public var ff:filefilter = new filefilter("images", "*.jpg;*.gif;*.png;*.pdf,*.jpg,*.jpeg,*.gif,*.png"); private var timestamp:string; private var imgloader:loader = new loader(); public var serverpath:string = "choose own server"; public function browseimage():void { browsebtn.addeventlistener(mouseevent.click, fnbrowse); } private function fnbrowse(e:mouseevent):void { fr.browse([ff]); fr.addeventlistener(event.select, handleselect); } private function handleselect(event:event):void { trace("uploaded image file name is: " + fr.name + " :: " + event.target.name); //testapp=(fr.name + " : " + event.target.name); var dt:date = new date(); //externalinterface.call("alert", fr.name); timestamp = dt.getfullyear() + "-" + dt.getmonth() + "-" + dt.getdate() + "-" + dt.gethours() + "-" + dt.getminutes() + "-" + dt.getseconds() +"_"+fr.name; var req:urlrequest = new urlrequest(serverpath + "uploadfiles.aspx?filename=" + timestamp); fr.addeventlistener(event.open, startloading); fr.addeventlistener(progressevent.progress, onfileprogress); fr.addeventlistener(event.complete, onfilecomplete); fr.addeventlistener(dataevent.upload_complete_data, check); fr.upload(req); track_txt.appendtext("fr: " + fr.name + "\nts:" + timestamp + "\nreq:" + req); } private function check(e:dataevent):void { } private function startloading(e:event):void { track_txt.appendtext("\n loading start"); } private function onfileprogress(event:progressevent):void { track_txt.appendtext("\n loading in progress"); var loaded:number=event.bytesloaded; var total:number=event.bytestotal; var pct:number = loaded / total; status_txt.text = math.round(pct) + "% uploaded server"; } private function onfilecomplete(e:event):void { track_txt.appendtext("\n loading complete"); fr.removeeventlistener(event.complete, onfilecomplete); loadimage(); } private function loadimage():void { track_txt.appendtext("\n loadimage"); imgloader.contentloaderinfo.addeventlistener( progressevent.progress, handleprogress ); imgloader.contentloaderinfo.addeventlistener(event.complete, handlecomplete); imgloader.contentloaderinfo.addeventlistener(ioerrorevent.io_error, handleimageloaderror); try { imgloader.load(new urlrequest(serverpath + "uploadfiles/" + timestamp)); } catch(error:error) { // error loading image trace("===>" + error); } trace("===>loadimage"); } private function handleimageloaderror(e:ioerrorevent):void { status_txt.text = "error : " + e; } private function handleprogress(event:progressevent):void { var percent:number = event.bytesloaded / event.bytestotal * 100; status_txt.text = math.round(percent) + " % loaded design"; } private function handlecomplete(e:event):void { var picw:int = picture.width; var pich:int = picture.height; imgloader.width = picw; imgloader.height = pich; trace("picture : " + picw + ":" + pich + " image : " + imgloader.width + ":" + imgloader.height); imgloader.contentloaderinfo.removeeventlistener(event.complete, handlecomplete); picture.addchild(imgloader); } }
once file gets uploaded server, load application.
also, script runs fine if there isn't space in file name of file uploaded.
any appreciated.
More discussions in ActionScript 3
adobe
Comments
Post a Comment