Warning: getimagesize: Unable to open '' for reading ...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
webcan
Forum Commoner
Posts: 66
Joined: Tue Oct 28, 2003 2:25 pm
Location: Toronto, Canada

Warning: getimagesize: Unable to open '' for reading ...

Post by webcan »

Hey again everyone.

Ok, I am getting this error message when I try to work with an uploaded file:

Code: Select all

Warning: getimagesize: Unable to open '' for reading. in /home/httpdocs/frames/profile.php on line 744
The HTML that has the form seems correct. It is as follows:

Code: Select all

<FORM ACTION="profile.php" METHOD="post">
	<INPUT TYPE="file" NAME="photo" SIZE="50" ACCEPT="image/jpeg">
	<INPUT TYPE="submit" VALUE="Upload Photo" CLASS="button">
	</FORM>
Pretty straight forward. Then, the PHP code that processes this is here (I took this from another post and slightly modified it):

Code: Select all

<?php
		$filetype = $_FILES["photo"]["type"];
		$filesize = $_FILES["photo"]["size"];
		$filename = $_FILES["photo"]["name"];
		$filetemp = $_FILES["photo"]["tmp_name"];
		$maxwidth = 400;
		$maxheight = 500;
		$savedir = "/home/httpdocs/images/user";
		$newfilename = rand(1111111111, 9999999999);
		$newfilename = date("md") . $newfilename;
		
		$imgsize = GetImageSize($filetemp);
		...
?>
Line 744 is the last line there, $imgsize = GetImageSize($filetemp);. When I try to print out the contents of $filename, $filesize, $filetype, or $filetemp, it's all blank.

Do I need any special permissions set somewhere?

I read from other posts that there may be a limitation in file size on uploading, but I tried this with a file that is less than 100 bytes and it still didn't work.

Your help is appreciated!

Thanks,
Peter.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Try adding this to the <form> tag........ enctype="multipart/form-data"....... so it's looks something like this...... <form enctype="multipart/form-data" action="_URL_" method="post">
webcan
Forum Commoner
Posts: 66
Joined: Tue Oct 28, 2003 2:25 pm
Location: Toronto, Canada

Post by webcan »

That worked - thank you!
Post Reply