I get the following error when trying to upload a .JPG file.
Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in H:\Programs\webserver\root\media\images\upload.php on line 43
The following is part of the upload.php file:
if(isset($_FILES['files']))
{
$cat = $_POST['cat'];
$title = $_POST['title'];
$album = $_POST['album'];
foreach($_FILES['files']['tmp_name'] as $key => $tmp_name)
{
// get dimensions of uploaded images
echo $temp = $_FILES['files']['tmp_name'][$key]; //location of file
echo $type = $_FILES['files']['type'][$key]; //image type
echo $size = $_FILES['files']['size'][$key]; // image size
>> line 43 >>**echo $size2 = getimagesize($temp); //function to get info of file and put into array**
echo $width = $size2[0]; // first part of the array is the image width
echo $height = $size2[1]; // second part fo the array is the image width
if($type == 'image/jpeg')
{
$filetype = '.jpeg';
}else{
$filetype = str_replace('image/','',$type);
}
$random_name = rand(1000,9999).rand(1000,9999).rand(1000,9999).rand(1000,9999);
$path = 'img/'.$random_name . $_FILES['files']['name'][$key];
$thumb_path = 'img/thumb_/'.$random_name .$_FILES['files']['name'][$key];
I have another .jpg image file that I have been uploading to test which uploads fine, also .png and .gif files also upload fine.
Just to add that I tried a couple more image files of a similar size and received the same error.
The first Image file was 4.2MB the second was 5MB. Why would the file size stop it uploading?
Also when using $_FILES[‘files’][‘error’][$key]; – it returns 1.
This is what i get when using print_r:
Array ( [files] => Array ( [name] => Array ( [0] => DSCN0354.JPG ) [type] => Array ( [0] => ) [tmp_name] => Array ( [0] => ) [error] => Array ( [0] => 1 ) [size] => Array ( [0] => 0 ) ) )
Lets look at the knowns:
These knowns lead me to believe that the problem image is too big for the current allowed
upload_max_filesizein your php.ini settings:Try increasing the size to 6M or 8M and your bigger image should work.