Page 1 of 1

Help with File Upload

Posted: Sun May 14, 2006 11:00 pm
by maverickbce8
i can find alot of file upload tutorials using PHP, and i can get started by creating the forum with html. I get stuck when i have to start using the php. I dont know where to save the php file and what i have to do to get the file upload to work correctly for my website. Please help....

Posted: Sun May 14, 2006 11:45 pm
by Burrito
show us what you have so far....

you'll need to get familiar with the $_FILES array and some of the functions that involve uploading files ie (is_uploaded_file(), move_uploaded_file(), etc).

best thing to do, is hit up the manual for assistance with those and then come back here with any specific problems you might have.

Posted: Mon May 15, 2006 12:19 am
by maverickbce8
i get to the point where i creat the forum for the browse, and submit buttons, where that works.. Its just past that where i get stuck


ex: "After the user clicks submit, the data will be posted to the server and the user will be redirected to uploader.php. This PHP file is going to process the form data and do all the work."

"Now we can finally start to write a basic PHP upload manager script! Here is how we would get the temporary file name, choose a permanent name, and choose a place to store the file.
PHP Code:
// Where the file is going to be placed
$target_path = "uploads/";

/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];

NOTE: You will need to create a new directory in the directory where uploader.php resides, called "uploads", as we are going to be saving files there."





The directions seem vague to me.....how do i make that php script work with the html code that made the original forum

Posted: Mon May 15, 2006 12:36 am
by s.dot
I wrote an image upload tutorial that's supposedly under review by the tutorials group. I've seen a whole bunch of image uploading problems lately.

Anyhoo,

the file that's uploaded will be in an array called $_FILES

if you do this

Code: Select all

echo '<pre>';
print_r($_FILES);
echo '</pre>';
You'll see a bunch of information about what was uploaded.

It is saved (temporarily) on your server (most likely in the /tmp directoy)

You'll need to become familiar with move_uploaded_file() and basic file handling functions.

Posted: Mon May 15, 2006 12:59 am
by maverickbce8
thats the thing.....i dont know what to do with that in dreamweaver