English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I can make upload forms in php that upload images to my server but what do i write for where i want their file to go.
I want the file to get sent to a folder called Uploads so what do i write in the file location. does it need to start with a "/" and end in a "/" as it never works.

2006-10-24 11:53:18 · 3 answers · asked by peter s 1 in Computers & Internet Programming & Design

3 answers

Here you go. Note the "C:\\Temp\\" is the upload path on the server that I have set. Replace that with the path on your server. Also not the two backslashes. The first is to excape the second. Here is the code
if (isset($_POST['submit'])){
//you will need to change the path to where you want to upload to.
$uploadDirFile = "C:\\Temp\\" . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['name'];
$uploadMsg = "";
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadDirFile)) {
$uploadMsg .= "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
$uploadMsg .= "There was an error: " . error_reporting(2039) . " uploading the file, please try again!";
}
}
?>

Upload File





















Upload File:







2006-10-24 12:41:16 · answer #1 · answered by Mark M 2 · 0 0

PHP stores the file in a temporary location -- you don't really have much control over that. But once it is uploaded, you can move it to where you want it using (unsurprisingly) "move_uploaded_file"

See here:

http://us3.php.net/manual/en/function.move-uploaded-file.php

2006-10-24 18:58:40 · answer #2 · answered by dsr 2 · 0 0

Read documentation for the move_uploaded_file() function:

http://www.php.net/move_uploaded_file

___________

2006-10-26 14:04:18 · answer #3 · answered by NC 7 · 0 0

fedest.com, questions and answers