Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2012, 09:44 PM   PM User | #1
bnorris
New Coder

 
Join Date: Jan 2012
Posts: 21
Thanks: 10
Thanked 0 Times in 0 Posts
bnorris is an unknown quantity at this point
Permissions Problem

Hi peeps,

I need help. This is part of a code that uploads images to my webserver however it wont assign permissions. I need the files that upload (pics) to have 775,, can anybody help?

[php]copy ($line[tmp_name], '../temp/' . $file);
$new = new_dim ($info[0], $info[1], $sizes[small][0], $sizes[small][1]);
resize ('../temp/' . $file, 'cp-thumbs/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
$new = new_dim ($info[0], $info[1], $sizes[thumb][0], $sizes[thumb][1]);
resize ('../temp/' . $file, '../thumbs/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
$new = new_dim ($info[0], $info[1], $sizes[large][0], $sizes[large][1]);
resize ('../temp/' . $file, '../images/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
$new = new_dim ($info[0], $info[1], $sizes[enlarge][0], $sizes[enlarge][1]);
resize ('../temp/' . $file, '../enlarge/' . $file, $info[0], $info[1], $new[x], $new[y], $info[2]);
unlink ('../temp/' . $file);
mysql_query ('INSERT INTO ' . $dbimgs . ' VALUES(\'0\', \'' . $_POST['id'] . '\', \'' . $file . '\')', $link);
mysql_query ('UPDATE ' . $dblist . ' SET images=images+1 WHERE id=\'' . $_POST['id'] . '\' LIMIT 1', $link);
$upload = true;
continue;[php]
bnorris is offline   Reply With Quote
Old 01-24-2012, 09:54 PM   PM User | #2
DarkLaika
New Coder

 
Join Date: Jan 2012
Posts: 53
Thanks: 8
Thanked 4 Times in 4 Posts
DarkLaika is an unknown quantity at this point
If you make the images upload into a folder with permissions 775 then they should all have 775 as their default permission.
DarkLaika is offline   Reply With Quote
Old 01-24-2012, 09:58 PM   PM User | #3
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
You'll want to use chmod - http://www.php.net/manual/en/function.chmod.php
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Old 01-24-2012, 09:58 PM   PM User | #4
bnorris
New Coder

 
Join Date: Jan 2012
Posts: 21
Thanks: 10
Thanked 0 Times in 0 Posts
bnorris is an unknown quantity at this point
Quote:
Originally Posted by DarkLaika View Post
If you make the images upload into a folder with permissions 775 then they should all have 775 as their default permission.
You would think but it dosent, It sets them to 600 Is it an Apache thing?
bnorris is offline   Reply With Quote
Old 01-24-2012, 10:03 PM   PM User | #5
bnorris
New Coder

 
Join Date: Jan 2012
Posts: 21
Thanks: 10
Thanked 0 Times in 0 Posts
bnorris is an unknown quantity at this point
Quote:
Originally Posted by BluePanther View Post
Hello Sir,

Not real good with PHP but should I insert a tag like this somewhere?

[php] chmod("/mydir", 755);[p]
bnorris is offline   Reply With Quote
Old 01-24-2012, 10:03 PM   PM User | #6
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,521
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by bnorris View Post
You would think but it dosent, It sets them to 600 Is it an Apache thing?
No its down to the filesystem settings of the host OS.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 01-24-2012, 10:07 PM   PM User | #7
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
Quote:
Originally Posted by bnorris View Post
Hello Sir,

Not real good with PHP but should I insert a tag like this somewhere?

[php] chmod("/mydir", 755);[p]
Yeah like that, but for all the files in the dir. You could do that using one of the recursive iterator SPL objects, or just track the files your uploading and chmod them through there (definitely the best option).
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Old 01-24-2012, 10:10 PM   PM User | #8
bnorris
New Coder

 
Join Date: Jan 2012
Posts: 21
Thanks: 10
Thanked 0 Times in 0 Posts
bnorris is an unknown quantity at this point
Quote:
Originally Posted by BluePanther View Post
Yeah like that, but for all the files in the dir. You could do that using one of the recursive iterator SPL objects, or just track the files your uploading and chmod them through there (definitely the best option).
This script is a photo uploader and it dose many a day. Funny thing is it works on other (unix) servers ok but not this Linux box Would it hel if I posted the whole page? pastebin??
bnorris is offline   Reply With Quote
Old 01-24-2012, 10:12 PM   PM User | #9
BluePanther
Senior Coder

 
Join Date: Jul 2011
Posts: 1,226
Thanks: 3
Thanked 171 Times in 171 Posts
BluePanther is on a distinguished road
Quote:
Originally Posted by tangoforce View Post
No its down to the filesystem settings of the host OS.
This.
__________________
Useful function to retrieve difference in times
The best PHP resource
A good PHP FAQ
PLEASE remember to wrap your code in [PHP] tags.
PHP Code:
// Replace this
if(isset($_POST['submitButton']))
// With this
if(!empty($_POST))
// Then check for values/forms. Some IE versions don't send the submit button 
Quote:
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
BluePanther is offline   Reply With Quote
Users who have thanked BluePanther for this post:
tangoforce (01-24-2012)
Old 01-24-2012, 10:15 PM   PM User | #10
bnorris
New Coder

 
Join Date: Jan 2012
Posts: 21
Thanks: 10
Thanked 0 Times in 0 Posts
bnorris is an unknown quantity at this point
Quote:
Originally Posted by BluePanther View Post
This.

Would you happen to know what setting in Apachie?
bnorris is offline   Reply With Quote
Old 01-24-2012, 10:18 PM   PM User | #11
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,521
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by bnorris View Post
Would you happen to know what setting in Apachie?
Again, it's down to the filesystem of the host OS

Not Apache, not the FTP server, the OPERATING SYSTEM.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:57 AM.


Advertisement
Log in to turn off these ads.