Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

File Upload - help Please

General discussions related to php

Moderators: macek, egami, gesf

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 http://www.xxxx.com/pdf_files/. 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 ------- http://www.xxxx.com/pdf_files/mydocument.pdf

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

Any help very much appreciated.
KevinR
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Jan 06, 2013 11:56 pm

Re: File Upload - help Please

Postby kiash001 » Wed Feb 27, 2013 4:06 am

http://www.xxxx.com/pdf_files/mydocument.pdf
it is not a valid path. Try like this->
$target_path = "pdf_files/".$_FILES['file']['name']
User avatar
kiash001
New php-forum User
New php-forum User
 
Posts: 16
Joined: Wed Feb 27, 2013 2:49 am
Location: Dhaka, Bangladesh


Return to PHP General

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron