File Upload - help Please

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Jan 06, 2013 11:56 pm

File Upload - help Please

Postby KevinR » Mon Jan 07, 2013 12:06 am

New to PHP so apologies up front if I am asking simple stuff....

I have successfully uploaded data from a simple form into a mySQL database. I now need to store the uploaded file 'mydocument.pdf' into a server directory This directory has write permissions set.

I use the following code:

if(move_uploaded_file($_FILES['name']['tmp_name'], $target_path))
echo "<BR> The file has been uploaded <BR>";
} else{
echo "<BR> There was an error uploading the file, please try again! <BR>";

//$name ------------- mydocument.pdf
//$tmp_name --------- /usr/var/tmp/phpLMyDFP
//target_path -------

The upload always fails, I get no error messages, so what am I doing wrong?

Any help very much appreciated.

User avatar
New php-forum User
New php-forum User
Posts: 16
Joined: Wed Feb 27, 2013 2:49 am
Location: Dhaka, Bangladesh

Re: File Upload - help Please

Postby kiash001 » Wed Feb 27, 2013 4:06 am
it is not a valid path. Try like this->
$target_path = "pdf_files/".$_FILES['file']['name']

Return to “PHP General”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests