Advanced Search

Results 1 to 3 of 3

Thread: How to check whether the input is file

  1. #1
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to check whether the input is file

    My script is like this :

    if (got image) { show the image }
    else { show the input file for user to upload the image }


    In the php script how to validate when user submit the form via post , the post got $_FILES information or not ?

    Thank in advance for your kind assistance . Tx

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    This is the sort of general question that is best answered by a tutorial or the php.net website.

    This part of the php.net website is designed to explain this clearly:
    http://php.net/manual/en/features.file-upload.php

    Unfortunately, that page is actually fairly technical and might be difficult if you're just starting out. But it's good information and I do suggest looking at it. A good way to start might be to copy some of the example code and play with it. Just be careful of course, and if you're not sure what you're doing, then I suggest working on a server only after you've backed up all of your files. Also, while you're learning this (and might not understand the security risks of file uploads) don't make this a public page-- don't share the URL with anyone. After you understand how it works, you can make it a public site.


    If that doesn't work for you (and it's not necessarily the best/only way to start), you should just use google to search for a "php file upload tutorial", and that should work.

    If you have any more specific questions, feel free to ask.

    In the php script how to validate when user submit the form via post , the post got $_FILES information or not ?
    See this page for detailed information: http://www.php.net/manual/en/feature...ost-method.php

    You can use something like the "validating file uploads" (Example #2) section on the page.

    Or if you simply want to know that a file was submitted, check that $_FILES['userfile']['name'] was submitted:
    if (isset($_FILES['userfile']['name'])) {
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a lot for the tip, will use the isset method to check for the $_FILES submission. Thanks a lot...

Similar Threads

  1. Resolved file upload check
    By ggalan in forum PHP
    Replies: 6
    Last Post: 09-18-2011, 12:23 AM
  2. Form field check for specific input
    By codeparrot in forum JavaScript
    Replies: 4
    Last Post: 01-15-2011, 05:22 AM
  3. Check a radio button when clicked on input field
    By PHP_Passion in forum JavaScript
    Replies: 1
    Last Post: 03-25-2010, 10:13 AM
  4. Check an External File To See...
    By Rockonmetal in forum Flash
    Replies: 6
    Last Post: 03-08-2007, 10:53 PM
  5. <input type=file keep the value in php???
    By kissmytoe in forum PHP
    Replies: 1
    Last Post: 06-22-2005, 04:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •