Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple image uploader not working
    text
    copied!<p>I'm attempting to create a multiple image uploader (think Coppermine) where the user clicks a button in an SWF, selects a file or multiple files, and then these files are uploaded to a directory.</p> <p>I have a PHP script that handles the uploading a file, and my Flash file iterates over the files in the <code>FileReferenceList</code> and sends the file to this PHP script to upload. The directory path in the PHP script is correct, and permissions set to 777.</p> <p>The contents of my ActionScript 3.0 class look like this:</p> <pre><code>package com.yourfightsite.imageupload { import flash.display.MovieClip; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.MouseEvent; import flash.events.ProgressEvent; import flash.external.ExternalInterface; import flash.net.FileFilter; import flash.net.FileReference; import flash.net.FileReferenceList; import flash.net.URLRequest; public class ImageUpload extends MovieClip { private var uploadURL:URLRequest; private var fileRef:FileReferenceList; public function ImageUpload():void { uploadURL = new URLRequest(); uploadURL.url = stage.loaderInfo.parameters.uploadUrl; fileRef = new FileReferenceList(); uploadButton.addEventListener(MouseEvent.CLICK, buttonClickHandler); } private function buttonClickHandler(e:MouseEvent):void { var imageFilter:FileFilter = new FileFilter('Images', '*.jpg'); fileRef.browse(new Array(imageFilter)); fileRef.addEventListener(Event.SELECT, fileSelectHandler); } private function fileSelectHandler(e:Event):void { for each(var fileToUpload:FileReference in fileRef.fileList) { addFileToQueue(fileToUpload.name); uploadSingleFile(fileToUpload); } } private function uploadSingleFile(file:FileReference):void { file.upload(uploadURL); file.addEventListener(Event.COMPLETE, completeHandler); } private function ioErrorHandler(e:IOErrorEvent):void { trace('ioErrorHandler: ' + e); ExternalInterface.call('console.error', e); } private function progressHandler(e:ProgressEvent):void { var fileRef:FileReference = FileReference(e.target); var percentUploaded:Number = Math.round((e.bytesLoaded/e.bytesTotal)*100); updateFileInQueue(e.target.name, percentUploaded); } private function completeHandler(e:Event):void { markFileInQueueAsComplete(e.target.name); } private function addFileToQueue(filename:String):void { ExternalInterface.call('addFileToQueue', filename); } private function updateFileInQueue(filename:String, percent:Number):void { ExternalInterface.call('updateFileInQueue', filename, percent); } private function markFileInQueueAsComplete(filename:String):void { ExternalInterface.call('markFileInQueueAsComplete', filename); } } } </code></pre> <p>The three methods at the bottom of the class fire JavaScript functions in my HTML page that add the file names to a file queue widget, and update the percent value next to them, and finally mark them as complete.</p> <p>However, when I select files, they are added to the file queue widget as expected and then nothing. The files aren't uploaded, the files in the file queue widget aren't updated, and no errors are thrown, either in the console (I'm using Chrome) or Flash when publishing my movie.</p> <p>Can any one see any mistakes in my ActionScript above?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload