simcoweb Posted August 24, 2006 Share Posted August 24, 2006 This code should upload a picture file to the designated folder. But.. it's not. NO pic is getting uploaded even though it provides a confirmation and no errors.[code]<html><head><title>Test Upload Form</title></head><body><?php //image upload test$file_dir = "/home2/wwwplat/public_html/images/";$file_url = "http://www.plateauprofessionals.com/images";if (isset($image)) { print "<center>Image path: $image<br>\n"; print "<center>Image name: $image_name<br>\n"; print "<center>Image size: $image_size bytes<br>\n"; print "<center>Image type: $image_type<p>\n\n"; if ($image_type == "image/gif" ) { copy ($image, "$image_dir/$image_name") or die("Could not copy"); print "<img src=\"$file_url/$image_name\"><p>\n\n"; } } ?><form action="<?print $PHP_SELF?>" method="POST" enctype="multipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="100000"><input type="file" accept=".jpg" size="20" name="image" title="Image Upload" /><br><input type="submit" value="Submit"></form>[/code]I've validated this code by comparing it to some code in a Learn PHP book. Anyone see why it doesn't work? Link to comment https://forums.phpfreaks.com/topic/18507-why-wont-the-images-upload-with-this-script/ Share on other sites More sharing options...
simcoweb Posted August 24, 2006 Author Share Posted August 24, 2006 Thanks for the post and the code suggestion. Unfortunately it just displays the submit button. No form field shows. Link to comment https://forums.phpfreaks.com/topic/18507-why-wont-the-images-upload-with-this-script/#findComment-79725 Share on other sites More sharing options...
ForumGuy Posted August 24, 2006 Share Posted August 24, 2006 [url=http://www.phpfreaks.com/forums/index.php/topic,104755.0.html]http://www.phpfreaks.com/forums/index.php/topic,104755.0.html[/url]try the code in this thread it works fine for me to upload pic ;)just change the relevant variables and your away ;D Link to comment https://forums.phpfreaks.com/topic/18507-why-wont-the-images-upload-with-this-script/#findComment-79807 Share on other sites More sharing options...
simcoweb Posted August 24, 2006 Author Share Posted August 24, 2006 It appears as though that code wasn't working and you were seeking help with it. Does it work?What i'm actually trying to do is create a upload a pic, create a thumbnail that uploads at the same time, and import data into the mysql database pertaining to all the form fields and the pic references. Link to comment https://forums.phpfreaks.com/topic/18507-why-wont-the-images-upload-with-this-script/#findComment-79912 Share on other sites More sharing options...
craygo Posted August 24, 2006 Share Posted August 24, 2006 This works for me. [code]<?php//image upload test$file_dir = "/home2/wwwplat/public_html/images/";$file_url = "http://www.plateauprofessionals.com/images";if (isset($_POST['submit'])) {$image_name = $_FILES['image']['name'];$image_size = $_FILES['image']['size'];$image_type = $_FILES['image']['type'];$uploadfile = $file_dir.basename($image_name);if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n";} else { echo "Possible file upload attack!\n";} print "<center>Image path: $file_dir<br>\n"; print "<center>Image name: $image_name<br>\n"; print "<center>Image size: $image_size bytes<br>\n"; print "<center>Image type: $image_type<p><br>\n\n"; print "<img src=\"$file_url/$image_name\"><p>\n\n";}?><form action="<?=$_SERVER['PHP_SELF']?>" method="POST" enctype="multipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="100000"><input type="file" accept=".jpg" size="20" name="image" title="Image Upload" /><br><input type="submit" name=submit value="Submit"></form></body></html>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/18507-why-wont-the-images-upload-with-this-script/#findComment-79953 Share on other sites More sharing options...
simcoweb Posted August 24, 2006 Author Share Posted August 24, 2006 Thanks Ray. Actually this script was a test to see if there was a problem with uploading images to my server since i've been working on another script that for some reason just won't upload the image and create the thumbnail. See this thread: http://www.phpfreaks.com/forums/index.php/topic,104388.45.htmlI'm creating a member profile page and a member's list/summary page. The profile will contain the full image and the summary page will have a thumbnail. I'm looking for code to parse the data for the profile entry form which also has a file upload field. The goal is to upload the original image and also create a thumbnail at the same time. The reference for each is entered into the mysql database so I can then summon them up in the profile display pages. Any ideas? Link to comment https://forums.phpfreaks.com/topic/18507-why-wont-the-images-upload-with-this-script/#findComment-79994 Share on other sites More sharing options...
ForumGuy Posted August 31, 2006 Share Posted August 31, 2006 yeah my code works, if you read the post ::)you would find the problem i have is with large file uploads, the php.ini and so on. Link to comment https://forums.phpfreaks.com/topic/18507-why-wont-the-images-upload-with-this-script/#findComment-83393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.