[PHP] Uploading multiple files?

Results 1 to 8 of 8
  1. #1
    Gamma Daevius is offline
    MemberRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    [PHP] Uploading multiple files?

    Hi,

    Is there a way, in PHP, to upload multiple files (ie: the content of a whole directory) from the client to the server? Because the html tag <input> with the attribute/value type="file" can only select a file, not a directory. So, is there a way to upload multiple files, where users select the directory instead of 20 files to upload...

    Thanks,

    Daevius


  2. #2
    Alpha Member evill33t is offline
    MemberRank
    Sep 2005 Join Date
    /int/Location
    2,603Posts

    Re: [PHP] Uploading multiple files?

    either
    make dynamic inputs with js (if one gets changed you add a new one)
    or upload a zip/rar that gets extracted server sided
    or use webdav

  3. #3
    Gamma Daevius is offline
    MemberRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [PHP] Uploading multiple files?

    That zip idea is great! Thanks, stupid that I haven't thought that up lol. Not sure what you mean with the JavaScript part...and I'm not sure if WebDAV will work...

    Thanks,

    Daevius

  4. #4
    Omega FragFrog is offline
    MemberRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,630Posts

    Re: [PHP] Uploading multiple files?

    A website must NEVER be allowed to just 'read' the entire contents of a directory on a client computer - this would be a huge security-risk.

    There are ActiveX plugins that can, and you can use some javascript to continue to give the user a file-input dialogue, though that might be rather anoying.

  5. #5
    Gamma Daevius is offline
    MemberRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [PHP] Uploading multiple files?

    Yeah, I know PHP can and shouldn't read client info. The zip/rar solution works...although 'upload_max_filesize' in php.ini should be somewhat higher than 2MB if you want to upload multiple files...can't do much against that ^^.

    Thanks for the replies :)

    Daevius

  6. #6
    Account Upgraded | Title Enabled! Darth is offline
    MemberRank
    Feb 2005 Join Date
    BoliviaLocation
    997Posts

    Re: [PHP] Uploading multiple files?

    just edit the php.ini file :P

  7. #7
    Gamma Daevius is offline
    MemberRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [PHP] Uploading multiple files?

    Yes, its no problem for myself. Its that users are lazy and hate software where they have to modify "system" files. OR they dont have access to it: You rent a domain + hosting and you have the upload problem, you cant just change the php.ini file of the complete hosting server :P. The hoster would never allow, because it affects all sites.

    I guess FTP or single file upload is the only way....

    Thanks for the reply though :)

    Daevius

  8. #8
    Omega FragFrog is offline
    MemberRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,630Posts

    Re: [PHP] Uploading multiple files?

    Well, as stated, there are other options. I know of plenty of sites with foto-upload capabilty that use ActiveX components to let you select an entire directory, though as I've never written one myself I do not know how difficult that is going to be.

    Personally I tend to demand user write some title for each foto, makes them think twice before just uploading any crappy pic they took, doesn't hurt them in my opinion



Advertisement