Jump to content

[SOLVED] File Upload - Should this work


brucensal

Recommended Posts

Hi,

 

I am going crazy as to why this does not work.  I am trying to upload 2 files from my form to my webserver and the send the file directory to the database.

 

Is this code correct and the i have a problem with my webserver permission, or have i done something wrong.

 

Below is the code and the error message.

<? 
$uploadDir = '/home/****/*****';

if(isset($_POST['upload']))
{
        $fileName = $_FILES['mugimage1']['fname'];
        $tmpName  = $_FILES['mugimage1']['tmp_name'];
        $fileSize = $_FILES['mugimage1']['size'];
        $fileType = $_FILES['mugimage1']['type'];
        $fileName2 = $_FILES['mugimage2']['fname'];
        $tmpName2  = $_FILES['mugimage2']['tmp_name'];
        $fileSize2 = $_FILES['mugimage2']['size'];
        $fileType2 = $_FILES['mugimage2']['type'];
        $cust_name = $_POST['cust_name'];
        $cust_email = $_POST['cust_email'];
        $mugtext = $_POST['mugtext'];
        $textcolour = $_POST['textcolour'];
        $ebayid = $_POST['ebayid'];

$filepath = $uploadDir . $fileName;

[color=red]$result = move_uploaded_file($tmpName,$filePath);
$result = move_uploaded_file($tmpName2,$filePath);[/color]
if (!$result)  {
echo "Error Uploading File";
exit;
}
$dbh=mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("******"); 

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
$fileName2 = addslashes($fileName2);
$filePath = addslashes($filePath); 
}     
////////////////////////////////////////////////	  	
////////////////////////////////////////////////
///////DO NOT CHANGE////////////////////////////

////////////////////////////////////////////////  
        
        $query = "INSERT INTO upload (fname, size, type, fname2, size2, type2, cust_name, cust_email, mugtext, textcolour, ebayid, path ) ".
                 "VALUES ('$fileName', '$fileSize', '$fileType', '$fileName2', '$fileSize2', '$fileType2', '$cust_name', '$cust_email', '$mugtext', '$textcolour', '$ebayid', '$filePath')";

        mysql_query($query) or die('Error, query failed');                    
      
    mysql_close($dbh);
  echo "<br>Files Uploaded<br>";      
}

?>

ERROR CODE:

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phporlAsc' to '' in /*****/*****/*****/mugorders.php on line 32

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpV50oyf' to '' in /*****/****/*****/mugorders.php on line 33

Error Uploading File

 

Thanks for you help.

Link to comment
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.