Strange problem with picture Upload
| From: | Labunski | Date: | Sat, 23 Apr 2005 14:44:58 +0000 |
| Subject: | Strange problem with picture Upload | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-213722@lists.php.net to get a copy of this message | ||
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.