File Uploading Trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
della
Forum Newbie
Posts: 3
Joined: Thu Oct 24, 2002 11:25 am

File Uploading Trouble

Post by della »

Hi,

I run a community oriented websites, where remote users/members need to be able to upload/update content in their assigned directory.

I wanted to create/borrow a php based FTP script, but the problem is that my host does not have the FTP module installed.

So, I'll have to use the HTTP based file capabilities of php. The problem here is that it seems to require that I make the directories writable (ie, 0777). I'd prefer not to allow that.

First, I am wondering if there is any way around this problem.

Next, it wouldn't be so bad if I could only have one temp directory that is writable for everyone to upload to. Then, the script could make the necassary file manipulations without requiring all the other directories to be writable.

I can't see to get my php code to work unless all directories are writable. Not cool.

Any suggestions? Thanks!

Jason
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

try http://www.hotscripts.com, they have quite a few uploading scripts, not sure if they have any http based though :?
della
Forum Newbie
Posts: 3
Joined: Thu Oct 24, 2002 11:25 am

coding not a problem

Post by della »

...ya, I've looked over various scripts (and there are some good ones).

But, coding things up is not really the problem. Rather, it is more to do with directory permissions and such. And, if php can only do file manipulation in an unsecure invironment.

All the scripts I've seen either assume the php ftp module is installed (not the case on my host), or that all directories are insecurely set to chmod 0777, which is an undesirable situation.

Jason
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

what do you mean with http upload?
http PUT method or what is described in http://www.php.net/manual/en/features.file-upload.php?
della
Forum Newbie
Posts: 3
Joined: Thu Oct 24, 2002 11:25 am

upload and copy

Post by della »

...yes, that's what I am doing. I have a simply file upload form, and then I use copy() to copy the file to the proper directory.

But, copy() only seems to work in an unsecure environment.

Jason
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Try move_uploaded_files() instead of copy(). This function will check to make sure that the file has been uploaded via PHP's HTTP POST upload mechanism and will return false if it hasn't.

Mac
Post Reply