3

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>
1
  • 1
    I'm not sure I've understood the problem. You tag your question as PHP. Are you displeased with the file name that the user picks? Commented Jul 27, 2011 at 13:09

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You'll also have to use something like PHP as a Script so you can move your uploaded file from the Webserver's temp-directory to somewhere where it can be saved persistent.

Look at this Tutorial for example.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.