FmanTheCoder Posted May 3, 2014 Share Posted May 3, 2014 Im making an only photo sharing website for school and there is an error when it gets teh size of the image that the person selected. Warning: getimagesize(): Filename cannot be empty in C:\xampp\htdocs\index.php on line 21 Here is the coding part of it. if (!isset($file)) echo "Please Select An Image"; else { $image = file_get_contents($_FILES['image']['tmp_name']); $image_name = addslashes($_FILES['image']['name']); $image_size = getimagesize($_FILES['images']['tmp_name']); if ($image_size==FALSE) echo "The Specified File Is Not A Picture."; else { if (!$insert = mysql_query("INSTERT INTO image VALUES ('$image_name', '$image_name', '$image')")) echo "Upload Error."; else { $lastid = mysql_insert_id(); echo "Image Uploaded.<p />Your Image:<p /><img src=get.php>"; } } } Im new to php so im not that good. But Thanks! Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 3, 2014 Share Posted May 3, 2014 did you read the error? it is fairly self explanatory, $_FILES['images']['tmp_name'] is empty. is your code checking if the upload worked before trying to use any of the uploaded file information? Quote Link to comment Share on other sites More sharing options...
FmanTheCoder Posted May 3, 2014 Author Share Posted May 3, 2014 did you read the error? it is fairly self explanatory, $_FILES['images']['tmp_name'] is empty. is your code checking if the upload worked before trying to use any of the uploaded file information? $file = $_FILES['image']['tmp_name']; This is the rest of the code and its before the code above. First the website gets the information, then uploads, then uses it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.