PHP uploading

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

roadkillbunny
New php-forum User
New php-forum User
Posts: 9
Joined: Sat Mar 22, 2003 4:03 pm
Contact:

PHP uploading

Postby roadkillbunny » Sat Mar 22, 2003 4:10 pm

Hey, I am triing to use the upload a file thorugh php using the move_uploaded_file(); function. How do I use it?

I did this:

$uploadfile = "/var/www/html/";
move_uploaded_file($_FILE['album_logo']['tmp_name'] $uploadfile);

The album_logo is the name of the input type file and the uploadfile was permissions of 777 and has the group apache.

What am I doing wrong?

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sat Mar 22, 2003 11:45 pm

no no no
i never use move_uploaded_files =)
use

copy() =)

roadkillbunny
New php-forum User
New php-forum User
Posts: 9
Joined: Sat Mar 22, 2003 4:03 pm
Contact:

Postby roadkillbunny » Sun Mar 23, 2003 10:12 am

Does it work too if I want to upload from une computer to another?

User avatar
pootergeist
New php-forum User
New php-forum User
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK
Contact:

Postby pootergeist » Sun Mar 23, 2003 11:15 am

move_uploaded_file is reccommended in the manual for a couple of important reasons.

1) it will only effect a file that has been uploaded by php and is accessible in the $_FILES array.
2) it moves it rather than creates a duplicate, moves that, terminates script and then deletes the unmoved temp version.

Always always always use move_uploaded_file if you are dealing with form uploaded files.

To get your script working - you need a comma in the parenthesised call to seperate the parameters. You also need to designate $uploadfile as a file rather than a directory - not easy to move a file and somehow make it a directory during the move.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest