tombot Posted November 30, 2009 Share Posted November 30, 2009 Hi Guys, I am hoping you can help. I am just learning PHP and have created a successful form that people fil out and it loads to my mysql database, but for the life of me I can get an upload image age to work. I dont get an error, I get promted to browse for the file but when i click upload, it just refreshes the page and nothing is loadeded into my mysql database, let me know if I nee to post my code. I attached the files. Thanks [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/183449-cant-upload-pictures-to-mysql-using-php-website-i-created/ Share on other sites More sharing options...
tombot Posted November 30, 2009 Author Share Posted November 30, 2009 Here is the other file [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/183449-cant-upload-pictures-to-mysql-using-php-website-i-created/#findComment-968330 Share on other sites More sharing options...
mrMarcus Posted November 30, 2009 Share Posted November 30, 2009 can you just post the files here, please. in [ code ][/ code ] tags. you will get 10x the responses now and in the future. Link to comment https://forums.phpfreaks.com/topic/183449-cant-upload-pictures-to-mysql-using-php-website-i-created/#findComment-968340 Share on other sites More sharing options...
mrMarcus Posted November 30, 2009 Share Posted November 30, 2009 k, checked it out real quick, and this line is your problem: if(isset($_POST['upload2']) && $_FILES['userfile']['size'] > 0) { $_POST['upload2'] to be precise. in your form, your submit button is named 'upload' .. so, change that to: if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { and you should be fine. EDIT: looking at your upload.php file, you are not moving the file from it's temporary position to a public folder .. you need to use move_uploaded_file(). and what is this: $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); you don't need that code. you can find the size/type/tmp_name, etc., without reading the file in that manner. Link to comment https://forums.phpfreaks.com/topic/183449-cant-upload-pictures-to-mysql-using-php-website-i-created/#findComment-968342 Share on other sites More sharing options...
tombot Posted November 30, 2009 Author Share Posted November 30, 2009 Thank you, that worked, now on to creating pages to display the database info. Link to comment https://forums.phpfreaks.com/topic/183449-cant-upload-pictures-to-mysql-using-php-website-i-created/#findComment-968348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.