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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.