Jump to content

Recommended Posts

I have a form with a an image upload, I want it so the move_uploaded_files() script occurs after the SQL query has successfully been completed, however the way I have tried to do this does not work, but works fine if I don't restrict it to a successful query, here's my code for that part of the form. Also take it that the variables and their contents are correct.

 

...
      $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error());
      $db = mysql_select_db($Dbname, $conn);

      $sqlNew = "INSERT INTO Clothing (ClothingCode,Description,ItemType,Price,NUSPrice,AvailableSizes,AvailableColours) VALUES('$ClothingCode','$Description','$ItemType','$Price','$NUSPrice','$AvailableSizes','$AvailableColours')";

      $rsNew = mysql_query($sqlNew,$conn)or die('Problem with query: ' . $sqlNew . '<br />' . mysql_error());      		

      if(mysql_affected_rows($conn) == "1")
      {
         $move_image = move_uploaded_file($image_temp, $dirupload.$ClothingCode.".jpg"); // <--- This is the culprit
         $Added = true;
         $NotExec = false;
      }
        elseif(mysql_affected_rows($conn) =="0")
        {
           $Added = false;
           $NotExec = true;
        ?>
           <div style="position:Relative; top:250px; left:200px; width:550px">   
           <span class="errmsg">Could not be added, <?php echo "$ClothingCode";?> may already exist!</span>
           </div>
        <?php
        
        }
        mysql_close($conn);
...

 

Can anyone see what I'm doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/88821-move_uploaded_files-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.