Last post Jan 21, 2017 07:24 PM by PatriceSc
Jan 20, 2017 04:43 PM|SANJISH KUMAR|LINK
I am using a fileupload control to upload multiple files to the server and save the file path to a database .However during data retrieval i am unable to display the file path from the database on the fileupload control. This means that every time a
user wants to modify a record he has to reselect all the files . I have surfed the net and found that this is impossible due to security reasons. I was told to use a text box and display the file path in that. But this isn't the solution i am looking for
Jan 20, 2017 05:01 PM|PatriceSc|LINK
Which kind of modification do you want to support?
It seems that perhaps when the form is submitted you take into account posted file and will remove existing files ??? Usually it is done by showing current files unchanged and if no file is posted, you just keep the current files attached to the edited item.
The UI allows to remove existing files explicitely or to add new files in addition to those previously uploaded.
Jan 21, 2017 01:51 AM|markfitzme|LINK
Browser manufacturers don't want you to be able to set this. You could easily insert a path for a file that could contain sensitive information.
The main reason though is we have no business or need for knowing the path a file came from. The path is useless to us as a developer since the server has no access to the original path of the filename. With this in mind, some browsers now no longer bother
to send the file path when uploading a file as it doesn't have any practical use on the server.
Jan 21, 2017 03:36 AM|SANJISH KUMAR|LINK
I want the Admin to see the filenames and path during data retrieval when he wants to modify a product record. Since the file path does not show in the file upload control he will have to reenter all the files he uploaded when he was adding a new
record . This will make him go crazy if there are several records he needs to modify . Also if he leaves the fileupload text as blank my program will not allow him to save the record as no files have been selected. Please give me a solution to this
Jan 21, 2017 01:17 PM|PatriceSc|LINK
It seems using a texrbox as suggested earlier is really the correct solution :
- the file upload control is not for editing an existing value. The only purpose of this control is to allow a user to select a file which is then uploaded to the web server
- if you want to show existing file names use a Label
- if a user needs to edit a file name stored server side use a textbox
- if the file content needs to be changed use a file upload control so that the user can provide the updated file (and so the user can left this blank)
- once the file has been uploaded, the client file path doesn't have meaning and is usually no more provided by browsers. You can still store files server side files in a folder structure or by suing tags to organize them their own way on the server
In summary the file upload control unlike all other controls is used to upload file data to a server and so unlikely other control it is not intended to "edit" an existing value but just to upload files (ore more precisely the content of files)...
Jan 21, 2017 04:47 PM|SANJISH KUMAR|LINK
Thanks for the solution. The only hitch is in modifying a product details record. What if the user selects files a.jpg , b.jpg and c.jpg while adding a record and while modifying wants to select a.jpg ,b.jpg , c.jpg and and x.jpg . Can you please
explain how to go about this using a textbox
Jan 21, 2017 07:24 PM|PatriceSc|LINK
Seems Im' not clear. A textbox would allow for example to rename a file on the server side if you have to provide this your users. Here for the edition the UI would show a list of files a, b and c with likely next to them the ability to delete a file.
Then if a user wants to add a file you'll just use a blank input type=file control so that he can select the x.jpg file. He could also select the b.jpg file if it needs to be updated on the server. And so on the server side you'll just process UPLOADED
files ie :
- b.jpg already exists and replace the current server side version
- x.jpg doesn't exists and is added to the current record
- a.jpg and c.jpg are not uploaded and the current files are just kept attached to the current record in your file table. This is not because the user doesn't upload them again that you should delete them.
In short it seems you consider input type=file as any other control ie as replacing entirely what you have so far (forcing users to upload again all files when editing the record). Instead you'll use this control to provide NEW or UPDATED files and you'll
just keep the files you already have on the server side unchanged...
Just check a Google Drive, Dropbox or OneDrive web site. You just upload new or updated files to a remote folder. Existing files are just kept unchanged and you don"t have to provide them all each time you want just to upload a NEW file...