uploading multiple files

  • susancbk
  • Proficient
  • Proficient
  • susancbk
  • Posts: 293
  • Loc: New York City

Post 3+ Months Ago

working with an example from the adobe docs to upload multiple files --

it seems to be working fine - all the traces of opening, uploading, how many bytes loaded, when each upload is done.

but then - when i check the server... not all the files get put there...and it seems to be random as to how many show up..ie say i upload 4 files sometimes 1 shows up, sometimes 3, etc.

here's the AS
Code: [ Select ]
import flash.net.FileReferenceList;
import flash.net.FileReference;

var listener:Object = new Object();

listener.onSelect = function(fileRefList:FileReferenceList) {
  trace("onSelect");
  var list:Array = fileRefList.fileList;
  var item:FileReference;
  for(var i:Number = 0; i < list.length; i++) {
    item = list[i];
    trace("name: " + item.name);
    trace(item.addListener(this));
    item.upload("http://www.yourdomain.com/");
  }
}

listener.onCancel = function():Void {
  trace("onCancel");
}

listener.onOpen = function(file:FileReference):Void {
  trace("onOpen: " + file.name);
}

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
  trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}

listener.onComplete = function(file:FileReference):Void {
  trace("onComplete: " + file.name);
}

listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
  trace("onHTTPError: " + file.name + " httpError: " + httpError);
}

listener.onIOError = function(file:FileReference):Void {
  trace("onIOError: " + file.name);
}

listener.onSecurityError = function(file:FileReference, errorString:String):Void {
  trace("onSecurityError: " + file.name + " errorString: " + errorString);
}

var fileRef:FileReferenceList = new FileReferenceList();
fileRef.addListener(listener);
fileRef.browse();
  1. import flash.net.FileReferenceList;
  2. import flash.net.FileReference;
  3. var listener:Object = new Object();
  4. listener.onSelect = function(fileRefList:FileReferenceList) {
  5.   trace("onSelect");
  6.   var list:Array = fileRefList.fileList;
  7.   var item:FileReference;
  8.   for(var i:Number = 0; i < list.length; i++) {
  9.     item = list[i];
  10.     trace("name: " + item.name);
  11.     trace(item.addListener(this));
  12.     item.upload("http://www.yourdomain.com/");
  13.   }
  14. }
  15. listener.onCancel = function():Void {
  16.   trace("onCancel");
  17. }
  18. listener.onOpen = function(file:FileReference):Void {
  19.   trace("onOpen: " + file.name);
  20. }
  21. listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
  22.   trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
  23. }
  24. listener.onComplete = function(file:FileReference):Void {
  25.   trace("onComplete: " + file.name);
  26. }
  27. listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
  28.   trace("onHTTPError: " + file.name + " httpError: " + httpError);
  29. }
  30. listener.onIOError = function(file:FileReference):Void {
  31.   trace("onIOError: " + file.name);
  32. }
  33. listener.onSecurityError = function(file:FileReference, errorString:String):Void {
  34.   trace("onSecurityError: " + file.name + " errorString: " + errorString);
  35. }
  36. var fileRef:FileReferenceList = new FileReferenceList();
  37. fileRef.addListener(listener);
  38. fileRef.browse();


and here's the php
Code: [ Select ]
<?PHP
$target_path = "files/";
$target_path = $target_path . basename( $_FILES['Filedata']['name']);

if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path))
{
   echo "The file ". basename( $_FILES['Filedata']['name']). " has been uploaded";
}
else
{
   echo "There was an error uploading the file, please try again!";
}
?>
  1. <?PHP
  2. $target_path = "files/";
  3. $target_path = $target_path . basename( $_FILES['Filedata']['name']);
  4. if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path))
  5. {
  6.    echo "The file ". basename( $_FILES['Filedata']['name']). " has been uploaded";
  7. }
  8. else
  9. {
  10.    echo "There was an error uploading the file, please try again!";
  11. }
  12. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 18 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.