joecool2005 Posted April 16, 2007 Share Posted April 16, 2007 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 More sharing options...
aalbetski Posted April 16, 2007 Share Posted April 16, 2007 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 More sharing options...
joecool2005 Posted April 16, 2007 Author Share Posted April 16, 2007 Thanks for your help.I'm a little bit confused.What should I use for the method? Post or Get?Why should I use this line if I know the method? if (Request.ServerVariables("Request_Method") == "POST") {} Thx Link to comment Share on other sites More sharing options...
aalbetski Posted April 16, 2007 Share Posted April 16, 2007 I corrected my text (removed the 'GET')The very first time the page loads it will not be a POST, thats' why you use the check. You want to know that the page is posting its data Link to comment Share on other sites More sharing options...
jesh Posted April 16, 2007 Share Posted April 16, 2007 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 More sharing options...
joecool2005 Posted April 16, 2007 Author Share Posted April 16, 2007 Thx for your replyThe code below is it inside the <form> tag? <%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 More sharing options...
aalbetski Posted April 16, 2007 Share Posted April 16, 2007 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 More sharing options...
joecool2005 Posted April 16, 2007 Author Share Posted April 16, 2007 I've tried that code and it did not work.You can try ithttp://imf/IM/scripts/charles/addTaskForm.aspthx a lot Link to comment Share on other sites More sharing options...
aalbetski Posted April 16, 2007 Share Posted April 16, 2007 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 More sharing options...
justsomeguy Posted April 16, 2007 Share Posted April 16, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now