Reputation: 18590
I have a form that contains an html file browse button ( <input type=file />
). User select a file by clicking browse button and submit the form. On form submission new php script (submitToServer.php) is called that use that file to upload it to the server.
Now I want to upload that file without using browse button because file name and path is always same when we upload. How can I do this?
currently submitToServer.php file handle file using browse button like this:
$errorCode = $_FILES['claimsfile']['error'];
$claimsFileLocation = $_FILES["claimsfile"]["tmp_name"];
$claimsFileName = $_FILES["claimsfile"]["name"];
$claimsFilePointer = fopen($_FILES["claimsfile"]["tmp_name"], "r");
Upvotes: 0
Views: 1685
Reputation: 382806
I suspect that's not possible due to security reasons, you do have to click the browse button and specify a file first. Pre-filling this field with some tricky paths (../../etc)
and not pressing the browse button would have created security problems (if you could imagine for a while)
Upvotes: 3
Reputation: 48367
You can't. HTML does not allow it for security reasons.
The only way to control which file is uploaded from serverside would be to use an applet (java, activeX, flash) - and even then you'll need to use signed code to get out of the sandbox.
C.
Upvotes: 2