visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: PHP to access a .htaccess protected folder


By: collegeBoy U.S.A.  Date: 23/03/2003 00:00:00  English  Points: 75 Status: Answered
Quality : Excellent
I made a script that uses the copy() function to upload a file to a directory on the server. The script works just fine when I leave the directory unprotected. However, I have protected the directory with .htpasswd and .htaccess so that the files that are uploaded are not public domain. This makes the PHP script return an error in the browser:

Warning: Unable to create '/home/.1qaz/vault/files.url.com/vault/DSCF0025.JPG': Permission denied in /home/.1qaz/vault/files.url.com/index.php on line 11

If I understand this correctly, it means the PHP script has no authority to get around the .htaccess authentication. I would like a way to pass authentication to the directory, or get around the whole authentication process altogether.

What would you recommend?
By: VGR Date: 23/03/2003 20:20:00 English  Type : Comment
authorizing the Apache/IIS user to access this directory.
OR enable localhost access to it (the server is running locally)
By: collegeBoy Date: 23/03/2003 20:36:00 English  Type : Comment
The server isn't running locally. I simply have an account with a provider.

Is this something I can request of the administrators? Would they be willing? :) I suppose I can ask.

Thanks! Any other recomendations that I can do without administration help?
By: VGR Date: 23/03/2003 20:50:00 English  Type : Answer
ho, then it's for sure (99%) a problem of access right for you

sure : ask the provider for the cause of the error, as I think you're not doing anything forbidden

(except if YOU created the directory you try to write in, using FTP for example. Then you should set appropriate permisisons like 777)
By: collegeBoy Date: 23/03/2003 21:02:00 English  Type : Comment
HA! It worked. Thanks VGR, that was great advice.

The folder had 666 permissions, instead of 777.

:)
By: VGR Date: 23/03/2003 21:18:00 English  Type : Comment
classical :D
By: TheFalklands Date: 23/03/2003 21:27:00 English  Type : Comment

For those of you keeping score at home, please note that the copy() function DOES NOT bother to take into account any settings you have in .htaccess . This is applicable to ANY file manipulating function in PHP or otherwise (fopen, fwrite, file, etc).

The reason? .htaccess is an APACHE ONLY thing. It is NOT a file control mechanism of the operating system.



Do register to be able to answer

EContact
browser fav
page generated in 346.049790 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page