Re: Strange problem with picture Upload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PS You are inserting the image info into the database even if it's not a
valid JPEG or GIF and you are throwing it out -- That's probably NOT what
you really want to do anyway.  So even if that's not what is wrong in this
case, your logic is a bit "off" in that part.


On Sat, April 23, 2005 7:44 am, Labunski said:
> Hi guys,
> I have to say, I've written so many scripts that had file upload functions
> included,
> but this time something strange is happening.
>
> The script passes the IMAGE_TYPE check, and picture's name stores in the
> database (so I guess the picture should have been stored in the dir.), but
> when I look at the ftp - there's no picture in the upload directory.
>
> Chmod of the directory is 777;
>
> Here it is:
>
> $realdir = $_SERVER['DOCUMENT_ROOT'].'/img/';
> $uploadfile = $realdir. basename($_FILES['postbilde']['name']);
>
>         if (move_uploaded_file($_FILES['postbilde']['tmp_name'],
> $uploadfile)) {
>                $put_name_en = $_POST['subject_en'];
>
>                 if (!empty($put_name_en)) {
>                         $image = basename($_FILES['postbilde']['name']);
>                         $check_image =
> $_SERVER['DOCUMENT_ROOT'].'/img/'.$image;
>
>                         if( (exif_imagetype("$check_image") ==
> IMAGETYPE_JPEG)||(exif_imagetype("$check_image") == IMAGETYPE_GIF) ){
>                         $put_img = $image;
>                         }else{
>                         $img_root = $_SERVER['DOCUMENT_ROOT'].'/img/';
>                         $kick = $img_root.$image;
>                         unlink($kick);
>                         $put_img = '';
>                         }
>
>                         mysql_query("INSERT INTO data (subject_en, img)
> VALUES ('$put_name_en', '$put_img')") OR die(mysql_error());
>
>                         echo '<META HTTP-EQUIV="Refresh"
> CONTENT="0;URL=update.php">';
>                 }
>         } else {
>            echo "The upload was unsuccessful !";
>         }
>
>
> Sorry for my bad english,
> Thank you in advance,
> Lab.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux