/    Sign up×
Community /Pin to ProfileBookmark

upload permission problems

Hey there,

I’m trying to write a simple bit of code to upload a file. The annoying thing is that this code was working a week or two ago when I first wrote it, and now it’s not. The problem comes when I try to move the uploaded file from the tmp directory to its final destination and I get the old “…failed to open stream: Permission denied in…” The folder permissions are 0755, and can’t be chmod’d (“Operation not permitted in…”). Also, I’m not sure how to SSH to this server, so can’t get to the folder that way – anyway, I’m not sure I want to set the permissions to 0777.

Is it possible to make my page log into the server so that it’s not just an anonymous user running the script?

Even if I log in to the cpanel of the site from this computer, I still get the permissions error – I wondered if that might have been the difference between last time and this time; obviously not.

Any suggestions?!

Big thanks in advance,

Mat

[Edit: ALSO, there appears to be two folders with my php in it – …/www/ and …/public_html/ $_SERVER[‘document_root’] indicates that the file is running in public_html, but I’m pretty sure I upload to www – are the two folders just mirrors of each other or what?!?!]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsDec 31.2004 — you will need to chmod the directory to 0777
Copy linkTweet thisAlerts:
@matstuffauthorDec 31.2004 — The directory won't allow this. I get an error when I try. And anyway, aren't there security issues with setting it to 0777?
Copy linkTweet thisAlerts:
@AdamGundryDec 31.2004 — Yes, setting the directory to 0777 would mean it was writeable to all users on your server, which could potentially be a problem. It sounds like the directory is owned by a different user to the user running the PHP script (which will probably be the web server user, such as apache), since otherwise 0755 would be ok.

I don't know what's going on with the folders - perhaps one of them is a link to the other?

Adam
×

Success!

Help @matstuff spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...