SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to do this...

    Hi,

    sorry for the ambiguious title!

    I want to to write some logic that says if this file array has this name then do this.....what i mean is if someone has selected a file from their hard drive in to a file upload box with a name attribute of 'file_field' and uploaded the file how do i say in my script at the other end.....if the file array is called 'file_field' then do this....

    ive tried if($_FILES == 'field')

    But it doesnt work!

    any ideas?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    http://us2.php.net/features.file-upload

    PHP Code:
    if (isset($_FILES['file_field'])) 

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    if($_FILES['name'] == "field"){
    //then they did what you wanted/feared


    Do :

    print_r($_FILES);

    And have a good look what is being sent into your scripts.

    The all important one is $_FILES['error'] !

    Follow the link in the manual to see what errors 1 to 4 mean, save a sea of pain.



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
  •