Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: file upload

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    file upload

    I have a form with a file field and i want the value of the field to be set to what is selected from the database to be displayed.

    It only works when i change the type="text".
    The variable gives the location of the file on the server.
    The reason i want to it to be type="file" rather than "text" is i want them to be able to change the file if they want by clicking on "browse".

    Here's the code i have

    PHP Code:
     <input name="uploadedfile" type="file" id="uploadedfile" value=<?php echo $path?>>

  • #2
    New Coder
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    91
    Thanks
    21
    Thanked 0 Times in 0 Posts
    Try this:

    Code:
    <input name="uploadedfile" type="file" id="uploadedfile"><?php echo $path; ?>

  • #3
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i tried that but it just prints it on the form not actually in the field!

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,010
    Thanks
    2
    Thanked 312 Times in 304 Posts
    The form input type="file" is for uploading a file from the client's computer to the server. The file "browse" function operates on the folders/files on the client's computer. Also, for security reasons, you cannot place a value into a type="file" field (if you could do this, it would be possible to make a form that uploads any known file from the client's computer to a server without the client's permission or knowledge - the form can be automatically submitted.)

    Since you want to list a file on the server, do you in fact want to allow someone to browse the files in a folder(s) on your server and download one?
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    No i just want the name of the file which is in the database to be displayed in the field and if the user wishes to change that file to another file they can browse theyre own computer and upload a different file.
    thanks

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    You can't give file inputs values. Just display the image if they have one and if they upload one, replace it.


  •  

    Posting Permissions

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