cyanide_pierce — 2013-01-03T15:19:59-05:00 — #1
Works locally but not live.
My file location is piercemcgeough.co.uk/com533/wolfhatmartialarts/admin/addproduct.php
And where i want the image to go is piercemcgeough.co.uk/com533/wolfhatmartialarts/images/products/
Warning i get live is:
Warning: move_uploaded_file(../images/products/wolf - Copy.jpg): failed to open stream:
Permission denied in /usr/local/pem/vhosts/171950/webspace/httpdocs/piercemcgeough.co.uk/com533/wolfhatmartialarts/admin/addproduct.php on line 46
Warning: move_uploaded_file(): Unable to move '/usr/local/pem/vhosts/171950/tmp/phpOWqMkC' to '../images/products/wolf - Copy.jpg' in /usr/local/pem/vhosts/171950/webspace/httpdocs/piercemcgeough.co.uk/com533/wolfhatmartialarts/admin/addproduct.php on line 46
And this is my code.
$target = "../images/products/";
$target = $target . basename($_FILES['photo']['name']);
$pname = $_FILES['photo']['name'];
$ptemp = $_FILES['photo']['tmp_name'];
$ptype = $_FILES['photo']['type'];
$psize = $_FILES['photo']['size'];
Really confused and stuck
rubble — 2013-01-03T15:34:10-05:00 — #2
1/ Echo out your variables to see what they contain.
2/ This looks like your problem "Unable to move '/usr/local/pem/vhosts/171950/tmp/phpOWqMkC" as the file does not have an extension and it is to much of a coincidence to be a random name starting with php.
cyanide_pierce — 2013-01-03T16:01:21-05:00 — #3
Variables are as following
Also i tried the w3schools uploading and it didnt work. Worked locally but not live
rubble — 2013-01-03T16:05:20-05:00 — #4
As I say this looks wrong "ptemp: /usr/local/pem/vhosts/171950/tmp/phpWKgPrd" Again your tempory file is starting with php.
Have you changed the permissions on the ../images/products/ folder to either 777 or 755 ?
cyanide_pierce — 2013-01-03T16:08:10-05:00 — #5
Sorry im a bit of a noob with file uploads. Just have the code from above in the addproduct.php file and want it to locate the image up a level and back into images/products.
No idea about permissions. Im using blacknight hosting
cyanide_pierce — 2013-01-03T16:14:42-05:00 — #6
Actually im using htaccess to change .php to .html with this
RewriteRule ^(.*)\.html$ $1.php
rubble — 2013-01-03T17:16:29-05:00 — #7
Do you know if you are on a Windows or Linux server?
cyanide_pierce — 2013-01-03T17:20:11-05:00 — #8
Well im using apache so im assuming its linux.
Cant figure this out. Head is wrecked
rubble — 2013-01-03T17:28:24-05:00 — #9
As you say probably Linux
It looks like your problem is a permission one as you have the error "Permission denied ".
I am not sure if moving a file needs the folder permissions changing but I would try changing the permission of products to 777
In your FTP program when you look at the folder it probably has a permission of 644 try changing that to 777 - right click on the foldername - change permission. You may be able to set ti to 757 or 755 if this works.
cyanide_pierce — 2013-01-03T17:32:38-05:00 — #10
Should i do that to images folder and products folder within it?
cyanide_pierce — 2013-01-03T17:49:04-05:00 — #11
Everything working now. thank you ever so much