Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a default file name/directory for upload on web form by modifying the html

I use this upload form all of the time and use the same file name each time. I wonder if there is a way to set the file name in a form by changing the code and saving the file locally. If there other ways to automate this I'd be open to that too. Thanks.

Here is the source:

<html>
<body>

<form enctype="multipart/form-data" action="mibdata.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Choose a file to upload: <input name="uploadedfile" type="file"/><br />
<input type="submit" value="Upload File" />

</body>
</html>
like image 488
Jamie L. Avatar asked Nov 21 '25 09:11

Jamie L.


1 Answers

PHP Code: (in mibdata.php)


$target_path = "/path/to/save/file/filename.ext";
if(isset($_FILES['uploadedfile'])){
   move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);
}

Make sure that the target_path is writable by server.

like image 125
Ibrahim Avatar answered Nov 22 '25 23:11

Ibrahim