Can not upload image to server

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
senzacionale
Forum Newbie
Posts: 9
Joined: Wed Dec 05, 2007 8:51 am

Can not upload image to server

Post by senzacionale »

I want to upload image to server by PHP but i get this error
Warning: move_uploaded_file(/home/turoglas/domains/turisticnioglasnik.si/public_html/dodano/223627514__.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/turoglas/domains/turisticnioglasnik.si/public_html/sistem/admin/slike.php on line 26

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpzzUB0V' to '/home/turoglas/domains/turisticnioglasnik.si/public_html/dodano/223627514__.jpg' in /home/turoglas/domains/turisticnioglasnik.si/public_html/sistem/admin/slike.php on line 26
Unknown image
This is my code:

Code: Select all

define('CMS_FIZICNA_POT', '/home/turoglas/domains/turisticnioglasnik.si/public_html');
$datoteka = basename($_FILES['file']['name']);
$datoteka = pocisti_datoteke($datoteka);
//$datoteka = rand() . '_' . $datoteka;
	
$slikovna_pot = CMS_FIZICNA_POT . '/dodano/';
$pot = $slikovna_pot . $datoteka;

if(file_exists($pot)) 
{
	preusmeri_z_sporocilom('napaka', 'JEZIK_251', 'slike.php');
}

move_uploaded_file($_FILES['file']['tmp_name'], $pot);
/dodano is 777 permision but not working. Any idea why?
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Post by arjan.top »

looks like that you dont have write permission in folder /home/turoglas/domains/turisticnioglasnik.si/public_html/dodano/
senzacionale
Forum Newbie
Posts: 9
Joined: Wed Dec 05, 2007 8:51 am

Post by senzacionale »

i have 777 permissions but not wroking. I do not understand why not working. Maybe is problem safe_mod?
Last edited by senzacionale on Sun Dec 09, 2007 8:33 am, edited 1 time in total.
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Post by arjan.top »

chmodded via ftp?

CHeck if chmod is really 777 with:

Code: Select all

echo substr(sprintf('%o', fileperms('/tmp')), -4);
senzacionale
Forum Newbie
Posts: 9
Joined: Wed Dec 05, 2007 8:51 am

Post by senzacionale »

yes via ftp. I checked with your code and it is 0777. Very strange. Mabye is problem safe_mod, but i do not know if my provider use it?
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Post by arjan.top »

try

Code: Select all

echo ini_get('safe_mode');
senzacionale
Forum Newbie
Posts: 9
Joined: Wed Dec 05, 2007 8:51 am

Post by senzacionale »

Thank you arjan.top. I get blank page so safe_mod does not exist.

Any idea why upload then not working?

Thanks
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Post by arjan.top »

senzacionale wrote:yes via ftp. I checked with your code and it is 0777. Very strange. Mabye is problem safe_mod, but i do not know if my provider use it?
have you changed /tmp to your folder in my code? :D

Code: Select all

echo substr(sprintf('%o', fileperms('/home/turoglas/domains/turisticnioglasnik.si/public_html/dodano/')), -4);
senzacionale
Forum Newbie
Posts: 9
Joined: Wed Dec 05, 2007 8:51 am

Post by senzacionale »

yes i changed it and i get code 0777. This is full permissions but i can not upload files.
senzacionale
Forum Newbie
Posts: 9
Joined: Wed Dec 05, 2007 8:51 am

Post by senzacionale »

any idea maybe, i still did not solve my problem.

Thanks
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Code: Select all

echo phpinfo()
What are your results?

Have you contacted your hosting company and asked what they think?
Post Reply