The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End File won't upload

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #177908

    This has been a real hazzle. What’s wrong with my code?
    EDIT: the code messed up here so I pasted it on pastebin:


    What error do you get here?

    Is the directory where you are uploading to got the correct permissions?


    Check out this gist I did a while ago, see if any of this helps.


    What error do you get here?


    this is the HTML:
    <input type="file" name="file" accept="image/*" />

    …is there a form associated with this input? what is the value of its enctype attribute?

    //now is the time to modify the future file name and validate the file

    Note that you don’t actually validate anything about the file, other than its size. This is a severe security risk. For example, if you want an image, you should make sure you got an image and not an executable script (especially if you plan on saving it somewhere accessible via the web).

    move_uploaded_file($_FILES['file']['tmp_name'], '/images/'.$new_file_name);

    You have a directory named images/ in your server’s root directory?? or is this meant to be a relative filepath?


    I think he adopted some code from my Gist. As with all of my code that I post online, it’s only for demonstration purposes. So @schart make sure you’re performing checks depending on what your requirments are.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.