Security Issue Related to PHP Safe Mode

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

billinchina

General BillEstablished Member
Impact
20
I want to upload photos into a folder that is accessible to the world with file permissions 755. My php script only works when the permissions on the folder are 777. What can I do to make this safer? I'm running on a shared hosting account with php safe mode turned on (as always). I do not want to store the pics in a database, I just want to figure out some way to only allow my domain name or static ip to write to files and allow all others to read only.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
what you could do is chmod the folder you right to 777 write the file

then chmod it back to 755

<?php
// Read and write for owner, nothing for everybody else
chmod("/somedir/somefile", 0600);

// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);

// Everything for owner, read and execute for others
chmod("/somedir/somefile", 0755);

// Everything for owner, read and execute for owner's group
chmod("/somedir/somefile", 0750);
?>

http://uk2.php.net/chmod
 
0
Close
Can't use chmod function

It throws a warning cannot use error because the uid of the script is different that the file I'm trying to chmod. Probably need safe mode turned off for that too...
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

New: watch any domain
You can now watch domains on NamePros. We check each one and notify you when something changes. Search for a domain and press Watch on...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back