You are here: Re: [PHP] Strange problem with picture Upload « PHP « IT news, forums, messages
Re: [PHP] Strange problem with picture Upload

Posted by Richard Lynch on 10/30/47 11:14

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация