Input File default value
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7313
Printed Date: 31 March 2026 at 9:41pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Input File default value
Posted By: zMaestro
Subject: Input File default value
Date Posted: 16 November 2003 at 9:01am
|
Can I assign a default value for an Input of type File: this is the code: <input type="file" name=attach1 size="20">
the default value is a QueryString.
|
Replies:
Posted By: zMaestro
Date Posted: 16 November 2003 at 9:03am
|
i added the value but didn't work!! <input type="file" name=attach1 Value="<%= Request.QueryString("ImageFile") %>" size="20">
I made a script like this but didn't work too with the Input File!!
<input type="text" name=attachtext Value="<%= Request.QueryString("ImageFile") %>" size="20">
<input type="text" name=attachtext Value="" size="20" onfocus="value=document.Form.attachtext.value">
didn't work too, is there a way?
|
Posted By: Mart
Date Posted: 16 November 2003 at 9:41am
|
You can't set the value of a file field, for security reasons.
If it wasnt like that you could just use document.Form.attachtext.value
Then
document.Form.Submit()
to nick files off their pc.
|
Posted By: zMaestro
Date Posted: 16 November 2003 at 2:51pm
|
I want to upload a file to the server, and write its name in the database, i want to make it in one step, but I'm using an asp code that doesn't accept the Request.Form and uploading in the same time, I must use Request.QueryString, something about binary or so.
I made a file where the user browse for the image he wants to upload from his HDD, and when click on submit the file name enters the database, and then redirected to the page where he can upload the image. I don't want him to rechose the image again, just be uploaded automatically.
I tried to use a normal <Input text> but didn't work, must be of type <Input file>.
did I make it more clear now? or you are confused ?
|
Posted By: Scotty32
Date Posted: 16 November 2003 at 3:49pm
|
doesnt uploading a file stop you from using the Request.Form and you have to use "component.form" (component being the upload component eg ASPUpload.... well the "object name" anyway)
|
Posted By: zMaestro
Date Posted: 17 November 2003 at 2:23am
|
sure, that is why in the uploading page I am using Request.QueryString instead of Request.Form
I've ASPupload installed on my server but I don't know .. I think pure asp is simpler 
|
Posted By: MorningZ
Date Posted: 17 November 2003 at 6:31am
zMaestro wrote:
I've ASPupload installed on my server but I don't know .. I think pure asp is simpler 
|
thats quite a statement to make considering you can't get "pure asp" to work.... if you use ASPupload, you could have "normal" form fields on there and access them by uploadform.form("This Other Field")
------------- Contribute to the working anarchy we fondly call the Internet
|
Posted By: Scotty32
Date Posted: 17 November 2003 at 2:14pm
http://www.aspupload.com - www.aspupload.com and go to the Reference area, it helps you alot, ive used it alot
|
Posted By: zMaestro
Date Posted: 18 November 2003 at 2:30am
|
I didn't find any difference between the pure ASP upload I was using and the aspupload component. I still can't use Request.Form in my asp page.
I want to update a database using pure asp, and in the same time upload the file to the server, the main problem is I can't use Request.Form (I use to send the data to the database) and ENCTYPE="multipart/form-data" I use to upload the files with in the form.
The aspupload manual says:
Due to the "multipart/form-data" attribute of upload forms, your ASP script can no longer use the built-in Request.Form collection to access individual form items. AspUpload solves this problem by offering two collections of its own, Upload.Files and Upload.Form to provide access to uploaded files and text fields, respectively. |
This problem can be solved either by:
- being able to set a default value for the <Input File> so to read it from another page that doesn't use Request.Form in the script, so I be able to upload.
- being able to use ENCTYPE="multipart/form-data" with the Request.Form.
|
Posted By: zMaestro
Date Posted: 18 November 2003 at 2:32am
|
OR simply, what is the simplest way you use to upload files into your server and in the same time writing to database.
|
Posted By: Scotty32
Date Posted: 18 November 2003 at 3:32am
|
ok, i dont think you see the point here
what you do to upload, and add to your database is use that "encrypt" line thing in the <form> tag
then create on your "processing" page, the object for ASPUpload
then you can use upload.form which IS Request.Form ... you cant use Request.Form... it is replaced with upload.Form
(sorry if this "sounds" offenive" but..) do you get it now?
you create the object for ASPUpload, at the top of the page then you can use the Upload.Form("fieldname") to add to your database, i had loads of problems with this, untill i worked it out
here ya go, an example:
upload = createobject("aspupload")
*upload code*
*connect to table* rs.addnew rs("field") = upload.Form("field") rs.update rs.close
set upload = nothing
does that explain it better?
(PS i advice AGAIST copy & pasting my code above, as its wrong as i dont know the EXACT commands, but oviously you'll know them.. or can find them out, i just did it quick)
|
Posted By: zMaestro
Date Posted: 18 November 2003 at 4:58am
|
I read what you refered too, and I understand it, my problem is my page is complicated, it is not a simple code, uploading a picture is only a case from many cases. PLUS I use Request.Form passing Username and UserID and many other things through pages. (It is a control panel). there are also included pages containing Request.Form, I can't change all of them to Upload.Form 
Changing Request.Form to Upload.Form is not a solution for me...
The best solution is how can I set a default value for:
<input type="file" name="attach1">
like
<input type="file" name="attach1" Value="<%= Request.QueryString("ImageFile") %>">
or even like:
<input type="file" name="attach1" onfocus="value='the value here'">
is there a solution 
|
Posted By: MorningZ
Date Posted: 18 November 2003 at 5:59am
zMaestro wrote:
This problem can be solved either by:
- being able to set a default value for the <Input File> so to read it from another page that doesn't use Request.Form in the script, so I be able to upload.
- being able to use ENCTYPE="multipart/form-data" with the Request.Form.
| but you aren't reading what anyone is saying! neither of of those is possible!!
OK, imagine that prefilling a file input was fillable.... one could code a page to "pre-fill" that with "C:\WINDOWS\security\res1.log" and then say in javascript "form1.submit()".. bam, someone just took a file from your windows directory to their server... now while i have no idea what that file i used an example for does or is, i am sure there's files in the windows directory that you don't want someone else getting a hold of
Let's look at the second "option": when you use the "multipart" encoding type, you are drasticlaly changing the form, it is no longer usable with the "Request.Form" which is a method to goto the page header and extract text information.. when you encode the form to multipart, the post is now binary in nature
I can tell you haven't even taken the 5 mins to look at the ASPUpload documentation, because you'd see clear as day that the component has "Request.Form"-like ability to easily extract the "other" fields from the binary post
------------- Contribute to the working anarchy we fondly call the Internet
|
Posted By: zMaestro
Date Posted: 18 November 2003 at 1:06pm
|

I can tell you haven't even taken the 5 mins |
I took one hour studing the aspupload, still the same problem as i said. Upload.Form is not a solution for me, even if it is typically like Request.Form, that's why I neglected it from the very begining and tried searching fo another solution.
The page is inside a control panel, the user navigates through forms passing variables from one page to another. so, I can't use Upload.Form instead Request.Form, since the navigations forms are the same in the whole system, and the code updating the database are also the same in the whole system, i can't modify them now.
anyway...
thanks Scotty_32 thanks MorningZ
|
Posted By: Scotty32
Date Posted: 19 November 2003 at 2:00pm
|
well if you have loads of includes
why not have a
strMode = "upload"
if strMode = "upload" then upload.form("field") else Request.Form("field") end if
but back to the original topic (filling in a "file" input) ever thought about uploading the file the first time the user selects it? and adding it to the database? for if you need it for anyfiin else, since you dont need to upload it twice.... but if you need to have 2 copys in difference folders, why not "copy" the file using the database to find out the path/file name and copy it to where you need??? this would solve your problem
also ... ever thought about Cookies and a Common file to pass variables?
|
Posted By: Flamewave
Date Posted: 20 November 2003 at 1:40pm
Another solution: have a "upload file" button that opens a popup window, and have the popup window do all the work for you...nothing else to interfere with it then.
------------- - Flamewave
They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.
|
Posted By: zMaestro
Date Posted: 20 November 2003 at 2:24pm
|
Flamewave wrote:
Another solution: have a "upload file" button that opens a popup window, and have the popup window do all the work for you...nothing else to interfere with it then. |

This is exactly what I made, I made a javascript that submits the data to 2 pages, one of them is a pop up with the upload form.
worked perefect.
|
|