Upload all files from a directory

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
mikeybatesuk
Forum Newbie
Posts: 3
Joined: Tue Dec 02, 2003 10:45 pm
Location: Vancouver, BC, CA

Upload all files from a directory

Post by mikeybatesuk »

Does anyone know if there is any way of doing this?

The problems I face in creating a function/class that can handle this are:

User needs to select a directory not a file which (as far as I know) <input type="file"> doesn't allow. Any ideas?

(All files in this directory then needs to be parsed and only the filetypes allowed selected which is easy enough)

The selected files then need to be uploaded from the client machine to the server, however as the <input type="file"> won't have been used they won't be sitting in any temp directory on the server yet. How do I get them off the client machine manually in PHP?

Thanks for any help you can offer.

Mike Bates
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

You'd probably wanna look at the ftp functions.

http://ca2.php.net/manual/en/ref.ftp.php
mikeybatesuk
Forum Newbie
Posts: 3
Joined: Tue Dec 02, 2003 10:45 pm
Location: Vancouver, BC, CA

Post by mikeybatesuk »

Cheers, I was poking around in the dark there but they look like exactly what I'm after. Thanks for the pointer.

Mike
mikeybatesuk
Forum Newbie
Posts: 3
Joined: Tue Dec 02, 2003 10:45 pm
Location: Vancouver, BC, CA

Post by mikeybatesuk »

Afterplaying aroud with this some more I've decided that the ftp functions aren't going to work. I may be getting this wrong so please correct me if I'm looking at this wrong.

I can open up a connection to an ftp server easily enough but what I want to do is allow the user on the client machine to upload from a selected (or a preset) local directory. For the ftp functions to do this I would have to open an ftp connection from the web server to the client machine and I can't assume that the client machine will have an ftp server running on it for me to open a connection with.

I've given up on this idea for now and have decided to just get the user to upload files one by one. (unless anyone else has any bright ideas)
Post Reply