title: ActionScript 3: Can not Find Uploaded Files
body: <p>This is my first <strong>ActionScript 3</strong> application. It is supposed to <strong>upload data to specific location</strong>, which should be the www root location - the location where upload.php resides. </p>
  
  <p>After I run the ActionScript application, I can select the file and I can see that the data is being uploaded, but <strong>I can never find it</strong>. </p>
  
  <p>Would you be so kind, please, and help me to understand what is going on, and how can I find the uploaded data? I checked both: temporary files location, and the target destination. </p>
  
  <p><em>Here is the ActionScript code:</em></p>
  
  <pre><code>    package {
      import flash.display.Sprite;
      import flash.events.*;
      import flash.net.*;
      import flash.text.*;
      public class ch30ex2 extends Sprite {
          protected var fileRef:FileReference;
          protected var uploadButton:TestButton;
          protected var tf:TextField;
          protected const YOUR_UPLOAD_URL:String = "http://localhost/Saifa/www/upload.php";
  
          public function ch30ex2() {
              fileRef = new FileReference();
              fileRef.addEventListener(Event.SELECT, selectHandler);
              fileRef.addEventListener(Event.CANCEL, cancelHandler);
              fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
              fileRef.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
              fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
              fileRef.addEventListener(Event.COMPLETE, completeHandler);
  
              var btn:TestButton;
              btn = new TestButton(100, 25, "Browse...");
              btn.addEventListener(MouseEvent.CLICK, function(event:Event):void {
                  fileRef.browse();
              });
              btn.x = btn.y = 20;
              addChild(btn);
  
              uploadButton = btn = new TestButton(100, 25, "Upload");
              btn.addEventListener(MouseEvent.CLICK, function(event:Event):void {
                  fileRef.upload(new URLRequest(YOUR_UPLOAD_URL));
              });
              btn.x = 20; btn.y = 55;
              addChild(btn);
  
              tf = new TextField();
              tf.defaultTextFormat = new TextFormat("_sans", 11, 0);
              tf.multiline = tf.wordWrap = true;
              tf.autoSize = TextFieldAutoSize.LEFT;
              tf.width = 300; tf.x = 130; tf.y = 58;
              addChild(tf);
  
              cancelHandler(null);
          }
          protected function selectHandler(event:Event):void {
              tf.text = fileRef.name;
              uploadButton.mouseEnabled = uploadButton.tabEnabled = true;
              uploadButton.alpha = 1;
          }
          protected function cancelHandler(event:Event):void {
              tf.text = "";
              uploadButton.mouseEnabled = uploadButton.tabEnabled = false;
              uploadButton.alpha = 0.3;
          }
          protected function progressHandler(event:ProgressEvent):void {
              tf.text = "Uploading " + 
                  event.bytesLoaded + " / " + event.bytesTotal + "bytes ...";
          }
          protected function errorHandler(event:ErrorEvent):void {
              tf.text = event.text;
          }
          protected function completeHandler(event:Event):void {
              tf.text = "Upload complete!";
          }
      }
  }
  import flash.display.*;
  import flash.text.*;
  class TestButton extends Sprite {
      public var label:TextField;
      public function TestButton(w:Number, h:Number, labelText:String) {
          graphics.lineStyle(0.5, 0, 0, true);
          graphics.beginFill(0xa0a0a0);
          graphics.drawRoundRect(0, 0, w, h, 8);
          label = new TextField();
          addChild(label);
          label.defaultTextFormat = new TextFormat("_sans", 11, 0, true, false,
              false, null, null, "center");
          label.width = w;
          label.height = h;
          label.text = labelText;
          label.y = (h - label.textHeight)/2 - 2;
          buttonMode = true;
          mouseChildren = false;
      }
  }
  </code></pre>
  
  <p><em>and here is the PHP code, which is supposed to copy the temporary uploaded file:</em></p>
  
  <pre><code>&lt;?php
  move_uploaded_file($_FILES[‘Filedata’][‘tmp_name’], ‘./‘.time().$_FILES[‘Filedata’][‘name’]);
  ?&gt;
  </code></pre>
  
  <p><em>All the code is from <a href="http://actionscriptbible.com/" rel="nofollow">ActionScript Bible</a> book</em></p>
  
  <p>I would kindly like to ask for the following:</p>
  
  <ul>
  <li><strong>What can be the possible sources of my problem?</strong></li>
  <li><strong>Looks my code correct? It gets compiled by FlashBuilder without problems</strong></li>
  <li><strong>How can I identify source of my issue?</strong></li>
  <li><strong>If you would have an example of working ActionScript + PHP application, I would be happy to see it.</strong> </li>
  </ul>
  
  <p>As I spend hours after hours trying various things and combinations, I hope somebody might have had similar problem. Thank you.</p>