View Full Version : file upload

03-10-2007, 05:25 PM
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

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

03-10-2007, 05:30 PM
Try this:

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

03-10-2007, 05:35 PM
i tried that but it just prints it on the form not actually in the field!

03-10-2007, 05:41 PM
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?

03-10-2007, 05:46 PM
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.

03-10-2007, 08:11 PM
You can't give file inputs values. Just display the image if they have one and if they upload one, replace it.