|
|
#1 (permalink) |
|
Surpass Fan
Excelling Contributor
Joined in Feb 2004
Lives in Rotorua New Zealand
Hosted on Pass3
738 posts
Gave thanks: 0
Thanked 2 times
|
PHP / cron job - Oh just help if you can please.
I have a question from a client I am hosting. The question makes no sense at all to me being a programming idiot, but the team here is pretty smart so I thought I'd throw it open to the panel :-)
""we are trying to move images to another folder once processed. I tried using move_uploaded_file, but was unable to since the file was ftp'd up instead of sent up via HTTP PUT (which is a requirement of move_uploaded_file). So I tried using the rename php function which will not work - it gives an error saying "Permission denied". Is there a way to give the php script permissions to carry out regular file operations when it is run from within a person's browser (which can only happen if they have entered a password to get access to that file). The script will also be run from a CRON job. Could you check with the brains . Any help would be gratefully appreciated."" |
|
|
|
|
|
#2 (permalink) |
|
I'm Dope as Crack
Resident.
Joined in Mar 2004
Lives in Asheboro, NC
Hosted on Pass 7
13,036 posts
Gave thanks: 7
Thanked 29 times
|
What about using the copy() function? I don't know how you'd go about using it exactly, but from the look of it on php.net, it looks like a way to go. You'd just have to delete the file afterwards.
__________________
|
|
|
|
|
|
#4 (permalink) |
|
All Ur Base R Belong 2 Us
Excelling Contributor
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
|
When they upload via FTP, the files belong to their username. When they run a PHP script through the browser, the script is run as nobody. That's why they couldn't rename the file. The file would need to be writeable by the world (i.e. chmod'd to 666) before the php script could modify it.
PHP Cron Jobs are usually done in two flavors, "php /path/to/script" and "lynx http://site.com/location/to/script" If they do the cron jobs in the first way, php runs under their username, so the cron job can rename the file. If they do the lynx method, then it's the same issue as running it in their web browser. --------- If they decide to do the copy() method that David suggested, you could suggest to them to have the script also save the original filenames to a text file, and then create another cron job which reads that file and removes the originals. The cron job just has to be specifically ran as "php /path/to/script" to ensure the script has the proper permissions. That way they don't have to manually delete the files personally afterwards.
__________________
Nobody doing nothing |
|
|
|