copy(productImages/submitbutton.png) [function.copy]: failed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikesheridan5
Forum Newbie
Posts: 7
Joined: Thu Jun 19, 2003 12:50 pm
Location: IA

copy(productImages/submitbutton.png) [function.copy]: failed

Post by mikesheridan5 »

I am getting this error when uploading a file

copy(productImages/submitbutton.png) [function.copy]: failed to create stream: Permission denied in

i am on a linux server with mysql

here is some of my code
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"]))
{
copy($_FILES["userfile"]["tmp_name"], "productImages/" . $_FILES["userfile"]["name"]);
echo "<p>File uploaded successfully.</p><br>";
$image_path = $_FILES["userfile"]["name"];

Any suggestions???? any help would be greatly appreciated

Thanks! :idea:
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

The place where you are copying the file to is owned by another user or you don't have sufficent permissions to write to it, "chown" the dir to 775 or 777 depandant on your security concerns.

Regards,
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you tried using move_uploaded_file() instead of is_uploaded_file() and copy()?

Mac
mikesheridan5
Forum Newbie
Posts: 7
Joined: Thu Jun 19, 2003 12:50 pm
Location: IA

Post by mikesheridan5 »

Thanks so much it must be a thursday if i didnt see that =)
mikesheridan5
Forum Newbie
Posts: 7
Joined: Thu Jun 19, 2003 12:50 pm
Location: IA

Post by mikesheridan5 »

no twiglet mac ive never used that before i've always used is_uploaded_file and it's always worked so i just keep on using it =) if it aint broke dont fix it
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

But it's always good to try things that have been created specifically for the task you are trying to achieve. Check out:
http://php.net/manual/en/features.file-upload.php

Mac
mikesheridan5
Forum Newbie
Posts: 7
Joined: Thu Jun 19, 2003 12:50 pm
Location: IA

Post by mikesheridan5 »

Thanks alot twigletmac ill do some messing around and see what works better =)

Cheers
Post Reply