PHP problem with file upload

Discussion in 'PHP' started by Dimension, Jan 15, 2008.

  1. #1
    I am trying to solve a problem with <input type="file" /> using php.

    What currently happens is, the user enters a file path from their computer into the box, and then they hit submit. However after the page is posted back to itself, the box is wiped clean.

    What I would like to do is get the whole path name that the user puts into the file box to stay there after submit.

    I'm not the best programmer in the world so go easy on my and I would be grateful for any feedback.
     
    Dimension, Jan 15, 2008 IP
  2. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #2
    An easy way would be storing the value of the box to a variable (and use hidden forms if you want) and calling it back once the form is submitted.
     
    Dondon2d, Jan 15, 2008 IP
  3. rkquest

    rkquest Well-Known Member

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    140
    #3
    I don't think that will work. I believe you can't preset the value of a file upload field.
     
    rkquest, Jan 15, 2008 IP
  4. hostingcoupon

    hostingcoupon Peon

    Messages:
    447
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    As far as I know, you can not preset the value for a file input field, nor can you set it through javascript. This is a security measure. If the browser allows you to do so, then it would be quite easy to steal user files.
     
    hostingcoupon, Jan 15, 2008 IP
  5. shyju

    shyju Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    best hope , u can store this to as session variable
     
    shyju, Jan 16, 2008 IP
  6. Dimension

    Dimension Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    can any tell me how i go about doing that?
     
    Dimension, Jan 16, 2008 IP
  7. shyju

    shyju Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hv a look this

    1.in file upload page
    ---------------------
    <?php
    session_start();
    ?>
    <input type="file" name="uploadedfile" value="<?php echo $_session['filepath']" ?>/>

    2.in action page
    ---------------------------
    <?php
    session_start();
    $_session['filepath']= $_FILES['uploadedfile']['name'];
    ?>
     
    shyju, Jan 16, 2008 IP
  8. webexpert

    webexpert Banned

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    according to my experience.. what you want is not possible..
     
    webexpert, Jan 16, 2008 IP