简体   繁体   中英

getimagesize() isn't working?

So I failed to ask this question in an acceptable way earlier, but now I have done some revisions and am ready to present this in a better way.

Here's my code:

$image_filename = $_FILES['picture']['tmp_name'];
$image_info = getimagesize($image_filename);
$image_size = $image['size'];
$image_mime_type = $image_info['mime'];
$image_data = file_get_contents($_FILES['picture']['tmp_name']);

Expected Result: I wanted to use the getimagesize() function to get an array for me to get the information from the picture into the variables. I wanted to get the mime type, image size and all of that good stuff onto a separate table for the images with all of the information.

What I got: A big fat error. At this point of the script, the photo has already been validated, renamed and put into the actual folder. However, it says:

"Warning: getimagesize(why+_ec08de7e618ec331ce5d941d3735f24a.jpg): failed to open stream: No such file or directory in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\Coleman\Wonder Penguin\index.php on line 171"

The par that really makes me scratch my head is that it points to a folder on my own computer. I checked out the path and it doesn't even exist.

Does anybody have any ideas? I narrowed the problem to this part of the script.

Oh, and as an extra. I got the same problem for the file_get_contents() but I figured that if I solved the first problem then that would be the solution for this problem as well.

Thank you for your time!

A very common mistake. You have to define exactly what directory the image is in or else it will come up as an error. It won't go searching through the website for it. so this is how I did it:

getimagesize('files/'.$image_filename);

Thank you for the suggested edits. I'll be sure to format better in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM