5 Replies Latest reply on Aug 6, 2010 7:35 AM by djh88ukwb

    Flex upload component with PHP, says it uploads but file dosent appear on server

    djh88ukwb Level 1

      Hello all.


      I am trying to use a flex upload component found here - http://weblog.cahlan.com/files/FileUpload/FileUploadApp.html


      I have downloaded the source code. And brought it all into flash builder.


      I should note that i am using wamp server and have created the following folder structure.


      upload   (mian folder on server - address is  http://localhost/upload)

        - file (sub folder of upload)


      I then changed the following code on the FileUploadApp.mxml to this

                  private const _strDomain:String = new String("http://localhost/upload/");
                  private const _strUploadScript:String = new String(_strDomain + "upload.php");


      I then released the project, and saved it onto my wamp server, putting all the files in the "upload" folder.


      My upload.php file is as follows


      $errors = array();
      $data = "";
      $success = "false";

      function return_result($success,$errors,$data) {
          echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>");   

      function echo_errors($errors) {

          for($i=0;$i<count($errors);$i++) {

      switch($_REQUEST['action']) {

          case "upload":

          $file_temp = $_FILES['file']['tmp_name'];
          $file_name = $_FILES['file']['name'];

          $file_path = $_SERVER['DOCUMENT_ROOT']."/file";

          //checks for duplicate files
          if(!file_exists($file_path."/".$file_name)) {

               //complete upload
               $filestatus = move_uploaded_file($file_temp,$file_path."/".$file_name);

               if(!$filestatus) {
               $success = "false";
               array_push($errors,"Upload failed. Please try again.");

          else {
          $success = "false";
          array_push($errors,"File already exists on server.");


          $success = "false";
          array_push($errors,"No action was requested.");





      I havent changed anything in it apart from  $file_path = $_SERVER['DOCUMENT_ROOT']."/myFileDir";    to $file_path = $_SERVER['DOCUMENT_ROOT']."/file";   to match that on my server.


      WHen i then load the application using the following url http://localhost/upload/FileUploadApp.html

      I select a file to upload and press upload.  It then gives an alert saying "Upload Successful" File(s) have been uploaded.


      But when i come to check my server the file has not been uploaded.


      Any ideas?


      I assume its a php / server thing ??