Uploading images with php (Not that simple)
Posted: Mon May 24, 2004 2:27 pm
I have written some code to upload images on my web site, after testing it with various images I find that it sometimes returns empty values, for example the following code used with . JPG images taken on my Nicon coolpix returns the $file_name, $file_type and $file_temp_name values as being empty and the $file_size returns 0. Other images are not a problem, I even tried running the problem images through Photoshop as jpg and gif but it makes no difference, the image information is not read from these images although Photoshop can read the file size fine.
The code I am using as far as I know is the normal code used with php to read these values which is below:
Can anyone shine any light on what this problem might be?
The code I am using as far as I know is the normal code used with php to read these values which is below:
Can anyone shine any light on what this problem might be?
Code: Select all
<?php
$file_name = $_FILES['uploadfile']['name'];
$file_temp_name = $_FILES['uploadfile']['tmp_name'];
$file_size = $_FILES['uploadfile']['size'];
$file_type = $_FILES['uploadfile']['type'];
$file_name = trim($file_name);
echo "file_name=$file_name<br />file_size=$file_size<br />file_type=$file_type";
exit
?>