Jump to content

How to submit the file automatically


joecool2005
 Share

Recommended Posts

Hi,Is it possible to submit the file automatically?This how I do manually.-------------------------------------------------------------------<form name="oForm" action="/scripts/cpshost.dll?PUBLISH?<%=Application("PostingAcceptorUploadServerLocation")%>/scripts/charles/addTask.asp" enctype="multipart/form-data" method="post"><input type="file" name="oFile1" size="20"><input type="hidden" name="TargetURL" value="<%=Application("FileAttachments")%>/charles/"><p align="center"><input type="submit" value="Upload File"></p></form>-------------------------------------------------------------------Now I need to do automatically. As soon as the user go the page, the file should be submitted.So I need to assign a value to <input type="file" name="oFile1" size="20">. I don't know how.Thx

Link to comment
Share on other sites

you can post the page using a onload function<body onload="oForm.submit()">you can tell check if the page is being posted or notif (Request.ServerVariables("Request_Method") == "POST") {}But I don't think you can write to the value of the input type=file. This would work for any other control

<%var sFilename = "MyFile"%><%	if (Request.ServerVariables("Request_Method") == "POST")	{		%><input type="text" value="<%=sFilename%>" name="oFile1" size="20" /><%	}%>

Link to comment
Share on other sites

I use this to automatically attempt to upload the file as soon as the user selects a file from his/her filesystem:

<form id="theForm" enctype="multipart/form-data"><input type="file" id="theFile" onchange="document.getElementById('theForm').submit();" /></form>

Link to comment
Share on other sites

here is the entire page as I mocked up

<%@language=javascript%><%var sFilename = "MyFile"%><body onload="oForm.submit()"><form name="oForm" action="/scripts/cpshost.dll?PUBLISH?<%=Application("PostingAcceptorUploadServerLocation")%>/scripts/charles/addTask.asp" enctype="multipart/form-data" method="post"><%	if (Request.ServerVariables("Request_Method") == "POST")	{		%><input type="text" value="<%=sFilename%>" name="oFile1" size="20" /><%	}%><input type="hidden" name="TargetURL" value="<%=Application("FileAttachments")%>/charles/"><p align="center"><input type="submit" value="Upload File"></p></form></body>

Link to comment
Share on other sites

I never tested it. It was mocked up to show you 1. How to auto post the page back ( Is it possible to submit the file automatically?)2. How to determine if the page was posted 3. How to set a value when the page was posted back (I need to assign a value to <input type="file" name="oFile1" size="20">. )You cannot set the input type=file to a value. That was told to you by me as well as another user in another forum. I simply showed how to fill a value for an input field (other than the file type)

Link to comment
Share on other sites

Just to answer the original question without bringing up alternatives..

Is it possible to submit the file automatically?
No, it's not. It would be a major security threat if that were possible. Browsers specifically make it not possible to auto-fill a value for input type="file".
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...