input type="file" help needed - Macromedia Dreamweaver

This is a discussion on input type="file" help needed - Macromedia Dreamweaver ; I have a file upload form that is serving different information to my script in FF3 vs IE6. In FF, I get just the filename as desired, but IE gives me the full path with double slashes. Is this normal? ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

input type="file" help needed

  1. Default input type="file" help needed

    I have a file upload form that is serving different information to my
    script in FF3 vs IE6. In FF, I get just the filename as desired, but IE
    gives me the full path with double slashes. Is this normal? How do you
    deal with it.

    I have created a couple of test pages to demonstrate.
    http://www.eclipsme.com/uploadtest.php

    This is the form, which calls uploadtest2.php, which simply displays the
    contents of the variable 'filename':

    <form action="uploadtest2.php" method="get"
    enctype="multipart/form-data" name="form1">
    <p>
    <input name="filename" type="file" size="40" >
    </p>
    <p>
    <input type="submit" value="Update">
    </p>
    </form>


    I used 'get' so it would be easy to see the variable on the url. The
    same happens with 'post'.

    Thanks for any help,
    Harvey

  2. Default Re: input type="file" help needed

    eclipsme wrote:
    > I have a file upload form that is serving different information to my
    > script in FF3 vs IE6. In FF, I get just the filename as desired, but IE
    > gives me the full path with double slashes. Is this normal? How do you
    > deal with it.


    It sounds as though you are using $_GET and/or $_POST. You should be
    using the $_FILES array instead.

    http://docs.php.net/manual/en/features.file-upload.php

    --
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  3. Default Re: input type="file" help needed

    David Powers wrote:
    >
    > It sounds as though you are using $_GET and/or $_POST. You should be
    > using the $_FILES array instead.
    >
    > http://docs.php.net/manual/en/features.file-upload.php
    >

    Busted... But it doesn't work just replacing _POST with _FILES, does it?
    So here is the code you gave me. I didn't want to confuse the issue so I
    didn't mention that the first part of the script forms the query to
    update the database, but the other half of the script needs to upload
    the actual file. I thought I could just pull the file names out and pass
    them to the upload script, but I guess it is the input type=file that
    throws this logic off. Damn! 2 forward, 1 back.

    Suggestions?

    Thanks,
    Harvey


    // create an array of field names
    $fields = array('field1', 'field2', 'field3', 'field4');
    // prepare empty array for values
    $values = array();
    // check whether magic quotes enabled
    $strip = get_magic_quotes_gpc() ? true : false;

    // loop through the fields
    foreach ($fields as $field) {
    if (!empty($_POST[$field])) {
    // strip magic quotes if necessary
    $val = $strip ? stripslashes($_POST[$field]) : $_POST[$field];
    // add field name and value to array
    $values[] = "SET $field = '" .
    mysql_real_escape_string($_POST[$field]) . "'";
    }
    }
    // build query
    $sql = 'UPDATE myTable ' . implode(',', $values) . ' WHERE itemID = ' .
    $itemID;

  4. Default Re: input type="file" help needed

    eclipsme wrote:
    > Busted... But it doesn't work just replacing _POST with _FILES, does it?


    Not quite, but it's very similar. Replace $_POST[$field] with
    $_FILES[$field]['name'].

    --
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  5. Default Re: input type="file" help needed

    David Powers wrote:
    > eclipsme wrote:
    >> Busted... But it doesn't work just replacing _POST with _FILES, does it?

    >
    > Not quite, but it's very similar. Replace $_POST[$field] with
    > $_FILES[$field]['name'].
    >

    If I understand what I am reading, and I am not at all sure that I am,
    'name' is the filename as entered into the form, no? But then you would
    have to know the filename before you could get the filename.

    Ooh! My head hurts.

    Harvey

  6. Default Re: input type="file" help needed

    $_FILES[$field]['name'] is asking for the value of the array variable stored
    in the 'name' field. That would be the name of the file being uploaded.

    --
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs, Tutorials & Resources
    ==================


    "eclipsme" <none@nowhere.com> wrote in message
    news:gcjceb$c2f$1@forums.macromedia.com...
    > David Powers wrote:
    >> eclipsme wrote:
    >>> Busted... But it doesn't work just replacing _POST with _FILES, does it?

    >>
    >> Not quite, but it's very similar. Replace $_POST[$field] with
    >> $_FILES[$field]['name'].
    >>

    > If I understand what I am reading, and I am not at all sure that I am,
    > 'name' is the filename as entered into the form, no? But then you would
    > have to know the filename before you could get the filename.
    >
    > Ooh! My head hurts.
    >
    > Harvey



  7. Default Re: input type="file" help needed

    On 08 Oct 2008 in macromedia.dreamweaver, eclipsme wrote:

    > David Powers wrote:
    >> eclipsme wrote:
    >>> Busted... But it doesn't work just replacing _POST with _FILES,
    >>> does it?

    >>
    >> Not quite, but it's very similar. Replace $_POST[$field] with
    >> $_FILES[$field]['name'].
    >>

    > If I understand what I am reading, and I am not at all sure that I
    > am, 'name' is the filename as entered into the form, no? But then
    > you would have to know the filename before you could get the
    > filename.
    >
    > Ooh! My head hurts.


    Drop this into the page which processes the upload form. You'll get a
    look at the structure and contents of the $_FILES array.
    http://www.php.net/print_r

    <pre>
    <?php
    if ($_FILES) {
    print_r ($_FILES)
    }
    ?>
    </pre>

    --
    Joe Makowiec
    http://makowiec.net/
    Email: http://makowiec.net/contact.php

  8. Default Re: input type="file" help needed

    Joe Makowiec wrote:

    >
    > Drop this into the page which processes the upload form. You'll get a
    > look at the structure and contents of the $_FILES array.
    > http://www.php.net/print_r
    >
    > <pre>
    > <?php
    > if ($_FILES) {
    > print_r ($_FILES)
    > }
    > ?>
    > </pre>
    >


    Thanks Joe. There needed to be a ';' after the print_r command. I guess
    I'm not the only one that forgets them, am I? and no, I guess they never
    get automatic, do they? ;-o

    Anyway,I removed the entire if statement to verify that the $_FILES
    variable was not getting set and got this:

    Array
    (
    )

    So it appears to me that nothing is getting passed to the $_FILES[]
    array, right?

    Here is the code from my form.

    <form name="form1" method="post" action="test.php">
    ....3 other input fields, identical except for fieldnames...
    <fieldset>
    <legend>Audio</legend>
    <table border="0">
    <tr>
    <td><input type="text" name="existingaudio" id="date"
    value="<?php echo $row_cra['audio']; ?>"size="20">

    ....BTW - The field above is for info only, showing the existing entry. I
    would like to make this read only. It is not read by the script...

    </td>
    <td><input name="audio" type="file" size="40"></td>
    </tr>
    <tr>
    <td><input name="ID" type="hidden" id="ID" value="<?php echo
    $row_cra['ID'] ; ?>">
    <input type="hidden" name="agency" id="agency" value="CRA"></td>
    <td><input type="submit" value="Update">
    <input type="reset" value="Reset"></td>
    </tr>
    </table>
    </fieldset>
    </form>

    Thanks,
    Harvey

  9. Default Re: input type="file" help needed

    Murray *ACE* wrote:
    > $_FILES[$field]['name'] is asking for the value of the array variable
    > stored in the 'name' field. That would be the name of the file being
    > uploaded.
    >

    Thanks Murray. That makes more sense than my way! Still, the $_FILES
    array does not seem to being set. Please see my other post.

    Thanks,
    Harvey

  10. Default Re: input type="file" help needed

    If $_FILES is not being set, then your upload is not working.

    --
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs, Tutorials & Resources
    ==================


    "eclipsme" <none@nowhere.com> wrote in message
    news:gcknun$57i$2@forums.macromedia.com...
    > Murray *ACE* wrote:
    >> $_FILES[$field]['name'] is asking for the value of the array variable
    >> stored in the 'name' field. That would be the name of the file being
    >> uploaded.
    >>

    > Thanks Murray. That makes more sense than my way! Still, the $_FILES array
    > does not seem to being set. Please see my other post.
    >
    > Thanks,
    > Harvey



+ Reply to Thread
Page 1 of 2 1 2 LastLast