Jump to content

[SOLVED] any reason why this simple image upload isnt working?


scarhand

Recommended Posts

im working on a simple image upload script (my first try)

 

well i noticed that for some reason its not even recognizing a file being uploaded...ive tried using the phpfreaks simple image upload tutorial but that wont seem to work for me.

 

so heres what ive got and this wont even work:

 

<?php
if (isset($_POST['submit']))
{
  if (!empty($_FILES['myphoto']['tmp_name']))
  {
    echo "file has been selected";
  }
}
?>

<form method="post">
<input name="myphoto" type="file" class="normalinput">
<br>
<input name="submit" type="submit" value="Submit Registration">
</form>

You're missing a couple or parts from your form. You need to specify an enctype of '"multipart/form-data", and you also need so specify a maximum file size in your form(not sure how far you'll get with your testing before this actually becomes a necessity, but it will at some point). Try:

 

 

<form method="post" enctype="multipart/form-data">
<input name="MAX_FILE_SIZE" type="hidden" value = "1000000" />
<input name="myphoto" type="file" class="normalinput">
<br>
<input name="submit" type="submit" value="Submit Registration">
</form>

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.