Jump to content

Can't upload pictures to mysql using php website i created


tombot

Recommended Posts

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]

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.