move uploadded file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

move uploadded file

Post by franknu »

ok this code is saving just the path to the database so when i ask the picture to display just the frame shows up no file,

the file is not being uploaded to the directory

i am not getting error message


"/home/townsfin/public_html/business_images/");

Code: Select all

define ("UPLOADDIR", "/home/townsfin/public_html/business_images/");

// All POST vars to vars..
$BusinessName = mysql_real_escape_string($_POST['BusinessName']);
$Slogan       = mysql_real_escape_string($_POST['Slogan']);
//etc...

IF ($_FILES['Picture1']) :

  $moved1 = false;
  $moved2 = false;
  $moved3 = false;

  IF (is_uploaded_file($_FILES['Picture1']['tmp_name'])) :
    $uploadfile1 = $_FILES['Picture1']['name'];
    $fullpath1   = UPLOADDIR . $uploadfile1;
    $filename1   = $_POST['name']. "1";
    IF (move_uploaded_file($_FILES['Picture1']['tmp_name'],  UPLOADDIR .$filename1)) :
      $moved1 = true;
      echo "picture $fullpath1 uploaded";
    ENDIF;
  ENDIF;

  IF (is_uploaded_file($_FILES['Picture2']['tmp_name'])) :
    $uploadfile2= $_FILES['Picture2']['name'];
    $fullpath2 = UPLOADDIR . $uploadfile2;
    $filename2=$_POST['name']. "2";
    IF (move_uploaded_file($_FILES['Picture2']['tmp_name'],  UPLOADDIR .$filename2)) :
      $moved2 = true;
      echo "picture $fullpath2 uploaded";
    ENDIF;
  ENDIF;

   IF (is_uploaded_file($_FILES['Picture3']['tmp_name'])) :
    $uploadfile3= $_FILES['Picture3']['name'];
    $fullpath3 = UPLOADDIR . $uploadfile3;
    $filename3=$_POST['name']. "3";
    IF (move_uploaded_file($_FILES['Picture3']['tmp_name'],  UPLOADDIR .$filename3)) :
      $moved3 = true;
      echo "picture $fullpath3 uploaded";
    ENDIF;
  ENDIF;

  IF ($moved1 and $moved2 and $moved3) :
    $sql = "INSERT INTO `business_info` ";
    $sql .= "SET `BusinessName`= '$BusinessName', ";
    $sql .= "    `Slogan`= '$Slogan', ";
    $sql .= "    `Business_Address`= '$Business_Address', ";
    $sql  .= "    `Tel`= '$Tel', ";
    $sql .= "    `Website`= '$Website', ";
    $sql .= "    `Email`= '$Email', ";
    $sql .= "    `Fax`= '$Fax', ";
    $sql .= "    `type`= '$type', ";
    $sql .= "    `make`= '$make', ";
    $sql .= "    `Categories`= '$Categories', ";
    $sql .= "    `Keyword`= '$Keyword', ";
    $sql .= "    `Picture1`= '$fullpath1', ";
    $sql .= "    `Headline`= '$Headline', ";
    $sql .= "    `Slogan2`= '$Slogan2', ";
    $sql .= "    `Description1`= '$Description1', ";
    $sql .= "    `Description2`= '$Description2', ";
    $sql .= "    `Description3`= '$Description3', ";
    $sql .= "    `Picture2`= '$fullpath2', ";
    $sql .= "    `Picture3`= '$fullpath3', ";
    $sql .= "    `User_Name`= '$User_Name', ";
    $sql .= "    `Password` = '$Password' ";
    mysql_query($sql)or die("SQL Error: $sql<br>" . mysql_error());
  ENDIF;
ENDIF;
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

post the actual error message, please.
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post by franknu »

i dont have any error message, it is just that the picture is not being uploaded when i look in the folder

business_images
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post by franknu »

this is my whole display when i submit the picture

Code: Select all

Array
(
    [Picture1] => Array
        (
            [name] => antorcha.jpg
            [type] => image/pjpeg
            [tmp_name] => /tmp/phpxsE2em
            [error] => 0
            [size] => 6942
        )

    [Picture2] => Array
        (
            [name] => how-to-buy-gold-794601.gif
            [type] => image/gif
            [tmp_name] => /tmp/phpLq4Wsa
            [error] => 0
            [size] => 63527
        )

    [Picture3] => Array
        (
            [name] => libertystatue.gif
            [type] => image/gif
            [tmp_name] => /tmp/php0CnBs2
            [error] => 0
            [size] => 13106
        )

    [Picture4] => Array
        (
            [name] => 
            [type] => 
            [tmp_name] => 
            [error] => 4
            [size] => 0
        )

    [Picture5] => Array
        (
            [name] => 
            [type] => 
            [tmp_name] => 
            [error] => 4
            [size] => 0
        )

)
picture /home/townsfin/public_html/business_images/antorcha.jpg uploadedpicture /home/townsfin/public_html/business_images/how-to-buy-gold-794601.gif uploadedpicture /home/townsfin
Post Reply