Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 6th, 2004, 10:41 AM
Registered User
 
Join Date: Sep 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Dynamically populate Filefield

Can someone please inform me as to how to populate a File form element with a value pulled from a database to be used during an edit. The usual <input name="addpiclink" type="file" id="addpiclink" value="<%=(NewsItem.Fields.Item("NewsPic").Value)% >"> doesn't work.

The value being pulled is the fulll file name of the file that I am going to display further down the page.

Any help would be greatly appreciated.

Thanks,
Glenn
 
Old September 6th, 2004, 04:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

The file input type creates a field through which users can upload files from their local computer or network. The VALUE attribute specifies the name of the initial file, but it is typically ignored by browsers as a security precaution.

So you cannot do it that way. Can you explain on why you wanted to setting value to the file type element?

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 7th, 2004, 05:16 AM
Registered User
 
Join Date: Sep 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply.

What I wanted to do was have one page where admins could submit a form to a database with a file attached. There is then another page that you can go in and edit the record, which is why I wanted the form fields populated.

If all of the fields are not populated and submit is pressed, then it will overwrite the record with empty values.

I hope this makes sense. I would prefer to be able to pull this data from the database (stored as text) and populate the file objects value.

Thanks again for your help.

Glenn
 
Old September 7th, 2004, 06:17 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I've come across a similar problem, and a quick fix (only fix) is to display the value as plain text above the 'file' input type to show what is in the database, and have users (administrators) drill down again to select another file if thay have to.

Andy G
 
Old September 7th, 2004, 03:42 PM
Registered User
 
Join Date: Sep 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Andy.

Think I'm going to have to give up on this one. This option is still no good as I am not storing where the file came from in the first place, and even then there is no guarantee that it will be there.

There are going to be more than one admin too, so they may edit a record that they didn't create. I think the only workaround that I am going to have is to not be able to update the picture link part of the record and only edit the text, making sure that the update command excludes the picture link field.

Thank you all for your help.

Glenn
 
Old September 11th, 2004, 08:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Glenn,

You can try this to resolve that.

Use a hidden field, and once the File is browsed and selected, store that value from the FILETYPE control into hidden field. Use the value in hidden/text field always to write to database. (If that needs to be shown on the browser use text control, else use hidden field.) And in case of edit operation, show whatever is in database in to a normal text control that way you won't be losing the data when you update.

Here you go...
For Add -- Use FileType and Hidden Field, then Browse/select the file, set that on to HIDDEN field once selected, and use that HIDDEN field's value always to ADD to the database.

For Edit -- Use FileType and TEXT field, Display the data from database on to TEXT field, If needed to be browsed for a different file, then Browse/select the file, set that on to TEXT field once selected, and use that TEXT field's value always to update the database.

Hope that makes sense, and you don't have to give up on this at all;).
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically populate a label MaxGay2 VB.NET 2002/2003 Basics 27 November 15th, 2006 04:17 PM
Populate a field Hennie Access VBA 2 September 13th, 2006 12:32 PM
Populate Listview yves VB Databases Basics 1 February 6th, 2006 08:38 AM
Dynamically populate crystal report from .NET DTCT Crystal Reports 0 November 12th, 2004 11:46 AM
How to change filefield control's button text? shenliujun Javascript How-To 1 July 20th, 2004 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.