Need to fix final image upload problem

Hi everyone i need to fix a problem with this upload image code, it is always saying: There was an error during file upload!..because the result inside of the upload.php is always different of 1. check the two files and if you can help me it will be great :slight_smile:


<html>
<head>
   <link href="style/style.css" rel="stylesheet" type="text/css" />
   
<script language="javascript" type="text/javascript">

function startUpload(){
      document.getElementById('f1_upload_process').style.visibility = 'visible';
      document.getElementById('f1_upload_form').style.visibility = 'hidden';
      return true;
}

function stopUpload(success){
      var result = '';
      if (success == 1){
         result = '<span class="msg">The file was uploaded successfully!<\\/span><br/><br/>';
      }
      else {
         result = '<span class="emsg">There was an error during file upload!<\\/span><br/><br/>';
      }
      document.getElementById('f1_upload_process').style.visibility = 'hidden';
      document.getElementById('f1_upload_form').innerHTML = result + '<label>File: <input name="myfile" type="file" size="30" /><\\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\\/label>';
      document.getElementById('f1_upload_form').style.visibility = 'visible';      
      return true;   
}
</script>   
</head>

<body>
       <div id="container">
            <div id="header"><div id="header_left"></div>
            <div id="header_main">Ajax Upload</div><div id="header_right"></div></div>
            <div id="content">
                <form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload();" >
                     <p id="f1_upload_process">Loading...<br/><img src="loader.gif" /><br/></p>
                     <p id="f1_upload_form" align="center"><br/>
                         <label>File:  
                              <input id="file" type="file" name="file" size="30" />
                         </label>
                         <label>
                             <input type="submit" name="submitBtn" class="sbtn" value="Upload" />
                         </label>
                     </p>
                     
                     <iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
                 </form>
             </div>
         </div>     
</body> 
</html>   

upload.php


<?php
   // Edit upload location here
   $destination_path = "photos/";

   $result = 0;
   
   $target_path = $destination_path . basename( $_FILES['file']['name']);

   if(@move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
      $result = 1;
   }
   
   sleep(1);
?>

<script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script>   


Thanks