SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Addict
    Join Date
    Jun 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_FILES['path']['name'] from a hidden input

    Hello,

    What I'm trying to do is that i have the following.

    Code HTML4Strict:
    <input type="hidden" name="path[]" value="C:\\science01.txt" />

    how would i associate it in $_FILES? doing the following doesn't work.

    Code PHP:
    foreach ($_POST['path'] as $key => $value)
    {
     $path = $_FILES['path']['name'][$key];
    }

    it doesn't store the value in $_FILES. But when i do the following, it does read the value of 'path'.

    Code PHP:
    foreach ($_POST['path'] as $key => $value)
    {
     $path = $_POST['path'][$key];
    }

    Basically i want to store the value of a input field into $_FILES. How can i go on about doing this? thanks

  2. #2
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm pretty sure it's not possible... Only things that can be stored in $_FILES are; name (File's name), type (File's MIME type), size (File's size in bytes), tmp_name (Where's it's stored on the server while uploading), and error (If error code is given). Everything else has to be in either _POST or _GET...
    - the lid is off the maple syrup again!

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Nope, totally impossible as it would present a huge security risk to the user.
    Imaging if I set up a nice looking form that had the hidden file upload field set to grab the registry off your PC?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm! I don't think that is possible to use the hidden form object as file object. Whenever you use $_FILES, it must be from <input type="file" /> only and if you give a name $_FILES['path'] then it will look for <input type="file" name="path" /> not <input type="hidden" name="path" />

    I don't know i did understand what you mean or not.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Addict
    Join Date
    Jun 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    everyone understood me very well, so it's not possible? I'm trying to do a dynamic multiple upload system... i tried assigning the value to a "display: none" type="file" input, but because of enctype="multipart/form-data" in the form it's not working i guess.

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Why not do it like sitepoint does it? I think it works like this:
    The user presses "Upload" after finding the file. It then (using AJAX) uploads the file, and stores the file, and it's contents, in a database. It then presents a new file upload on the screen, and also displays the details of previous uploads.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Addict
    Join Date
    Jun 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not too sure how that's done.

  8. #8
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    [Wrong thread]
    Last edited by Jake Arkinstall; Oct 10, 2007 at 02:01.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  9. #9
    SitePoint Addict
    Join Date
    Jun 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Being 15 year old doesn't mean your not reliable, years back when i was 13 i used to help my brother with his university level calculus

  10. #10
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How old are you now?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  11. #11
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    There are ways around everything! If you want multiple uploads using AJAX you will need to use an iframe to capture the processing part of the script.

    Have a look at http://the-stickman.com/web-developm...-file-element/
    for a really nice way to do it

    And it does depend on what it is you are trying to achieve with it and could it be done in a 'normal' way?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  12. #12
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    OMG - I'm sorry - I was posting in the wrong thread.
    Don't do it then. It's immature and just pointless (and this is coming from a 15 year old!).
    Sorry - I (for some reason) thought you were the guy trying to get neopets passwords :S.

    Anyway, I agree with what spikez said - AJAX is best for multiple uploads.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  13. #13
    SitePoint Addict
    Join Date
    Jun 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    There are ways around everything! If you want multiple uploads using AJAX you will need to use an iframe to capture the processing part of the script.

    Have a look at http://the-stickman.com/web-developm...-file-element/
    for a really nice way to do it

    And it does depend on what it is you are trying to achieve with it and could it be done in a 'normal' way?
    I could easily do it the normal way, but i want it to have dynamic feel, i'll go through what you suggested


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
  •