Jump to content

moving uploaded files


franknu

Recommended Posts

this code is saving the path in the database but it is not moving the file into the directory

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

everything looks like it goes through, it is just not showing up in the database

[code=php:0]

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;
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/35626-moving-uploaded-files/
Share on other sites

this is my display

[code=php:0]

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
[/code]
Link to comment
https://forums.phpfreaks.com/topic/35626-moving-uploaded-files/#findComment-169174
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.