UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 27th July 2003, 03:51 PM   #1 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
PHP upload

Hi

I'm writing a script to allow contributors to upload pdf files to a site.

What I was wondering is, what permissions does the target directory need to accept the move_uploaded_file()'d file and make the file readable by a browser?

Goodyear
goodyear is offline   Reply With Quote
Old 27th July 2003, 04:37 PM   #2 (permalink)
leafish_paul
web monkey
 
leafish_paul's Avatar
 
Join Date: Apr 2003
Location: North Wales
Posts: 331
Send a message via ICQ to leafish_paul Send a message via MSN to leafish_paul
I think just read and write permissions for owner, group and public, or chmod 766. If that doesn't work, try read/write/execute allowed for all, or chmod 777.
__________________
paul byrne - web monkey
paul.leafish.co.uk | www.leafish.co.uk
leafish_paul is offline   Reply With Quote
Old 27th July 2003, 08:23 PM   #3 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
Will permissions set this way cause me security headaches?

The upload script is going to be restricted to two people who I know, so theoretically no-one else will have access to it anyway.
goodyear is offline   Reply With Quote
Old 27th July 2003, 08:54 PM   #4 (permalink)
leafish_paul
web monkey
 
leafish_paul's Avatar
 
Join Date: Apr 2003
Location: North Wales
Posts: 331
Send a message via ICQ to leafish_paul Send a message via MSN to leafish_paul
As far as I know, you have to set the permissions on the directory you wish to copy the uploaded file to to at least 766. Having read the PHP documentation, it even says "remember to do a chmod -c -v 0777 on the directory you want your uploaded files to be moved to."

Please someone correct me if I'm wrong! Perhaps you could set the directory's permissions to 777, then remove permissions one at a time (starting with public execute, then group execute, then public write, etc...) until the script breaks to avoid 'security headaches'.

You could always have a look at this, which may save you re-inventing the wheel.
__________________
paul byrne - web monkey
paul.leafish.co.uk | www.leafish.co.uk
leafish_paul is offline   Reply With Quote
Old 27th July 2003, 09:31 PM   #5 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
I like reinventing the wheel.

Seriously, though, I actually enjoy figuring this stuff out and doing it myself! (No, really... )
goodyear is offline   Reply With Quote
Old 27th July 2003, 09:38 PM   #6 (permalink)
leafish_paul
web monkey
 
leafish_paul's Avatar
 
Join Date: Apr 2003
Location: North Wales
Posts: 331
Send a message via ICQ to leafish_paul Send a message via MSN to leafish_paul
Sure, I know what you mean - its often nicer to write something yourself: its easier to read/understand and maintain, and does exactly what you want - pre-written packages can be overkill.

However, I would advise looking through the PEAR code - there's loads of good stuff in there, and that HTTP Upload one in particular covers all the important aspects of uploading files with HTML forms - namely vaildating the upload, file types and sizes and security. You'll probably ended up pulling a lot of code from it. I know I did... ;)
__________________
paul byrne - web monkey
paul.leafish.co.uk | www.leafish.co.uk
leafish_paul is offline   Reply With Quote
Old 27th July 2003, 09:39 PM   #7 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
It needs at least 757.

What are the implication for having a directory set to this?

And is there any way round it?
goodyear is offline   Reply With Quote
Old 27th July 2003, 09:55 PM   #8 (permalink)
leafish_paul
web monkey
 
leafish_paul's Avatar
 
Join Date: Apr 2003
Location: North Wales
Posts: 331
Send a message via ICQ to leafish_paul Send a message via MSN to leafish_paul
Quote:
Originally posted by goodyear
What are the implication for having a directory set to this?
Not sure, really. Probably only effects you if someone else can access your file area on the shared server you are on...? Or if someone manages to SSH in? I'm not that well-versed on this. I'm off to have a read. I've got several directories on different sites set to 777 for forums, CMS scripts we wrote ourselves and the like... never really worried about it...

Quote:
And is there any way round it?
Again, no idea. Not from what I could gather from the PHP docs tho... essentially the user that is running PHP or Apache ('nobody'?) requires write access to that directory... anybody else have a better idea of this than me?
__________________
paul byrne - web monkey
paul.leafish.co.uk | www.leafish.co.uk
leafish_paul is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 02:42 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309