Jump to content

POST image with form


fesan

Recommended Posts

Hello...

 

I have made a form that sends a some text and a picture to a php script.

The form posts to itself with [$_SERVER['REQUEST_URI'].

 

The form looks like this:

<form method="POST" action="'.$_SERVER['REQUEST_URI'].'">
    <label>Bilde:
    <input type="file" name="image" id="image" />
    </label>
    <br />
<label>comment:<br />
  <input name="comment" type="text" id="comment" size="50" />
  </label>
    <input type="Submit" name="Submit" id="Submit" value="Submit" />
    <br />
    </p>
</form>

 

The code that receives the image and the text looks like this:

if(isset($_POST['Submit']))

{
    //Some Size variables for the image and other preparations for the script.
	     
     if (isset($_FILES['image']['name']))
     {
       //resize and upload the image in two sizes.
echo "Done";
}
echo "did not receive picture";
}

 

The script stopped working when implementing it to my website. The file is included with a switch in index.php.

Does anyone have a clue to why it stopped working? the script fails at the  if (isset($_FILES['image']['name'])), so i guess that the picture cant get true somehow.

Link to comment
https://forums.phpfreaks.com/topic/190438-post-image-with-form/
Share on other sites

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.