Page 1 of 1

Can not upload image to server

Posted: Sun Dec 09, 2007 7:27 am
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?

Posted: Sun Dec 09, 2007 7:57 am
by arjan.top
looks like that you dont have write permission in folder /home/turoglas/domains/turisticnioglasnik.si/public_html/dodano/

Posted: Sun Dec 09, 2007 8:17 am
by senzacionale
i have 777 permissions but not wroking. I do not understand why not working. Maybe is problem safe_mod?

Posted: Sun Dec 09, 2007 8:23 am
by arjan.top
chmodded via ftp?

CHeck if chmod is really 777 with:

Code: Select all

echo substr(sprintf('%o', fileperms('/tmp')), -4);

Posted: Sun Dec 09, 2007 8:57 am
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?

Posted: Sun Dec 09, 2007 9:55 am
by arjan.top
try

Code: Select all

echo ini_get('safe_mode');

Posted: Sun Dec 09, 2007 12:01 pm
by senzacionale
Thank you arjan.top. I get blank page so safe_mod does not exist.

Any idea why upload then not working?

Thanks

Posted: Sun Dec 09, 2007 12:38 pm
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);

Posted: Sun Dec 09, 2007 12:46 pm
by senzacionale
yes i changed it and i get code 0777. This is full permissions but i can not upload files.

Posted: Mon Dec 10, 2007 3:03 am
by senzacionale
any idea maybe, i still did not solve my problem.

Thanks

Posted: Mon Dec 10, 2007 3:39 am
by alex.barylski

Code: Select all

echo phpinfo()
What are your results?

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