Forum OpenACS Q&A: Photo-album - Uploading multiple pictures.

I have over 3000 pictures and it doesn't seems doable to upload them one at a time.

Isn't there a way to upload more than one pictures in photo-album?

Thx.

Collapse
Posted by Jarkko Laine on
In Jeff's version, yes (see http://xarg.net/code/) . In the version in CVS, probably not.
Collapse
Posted by Yves Goldberg on
Thanks Jarrko

I tried Jeff's package but really didn't need the extra functionality so I just hacked the existing photo-add-2.tcl:

# MY OWN LINE:
ReturnHeaders
ns_write "[apm_header  "Photo upload"]
<h2>Uploading photos...</h2>
<p>
<ul>
"

if { $file_extension=="zip" } {
   set exdir [ns_mktemp /tmp/XXXXXX]
   ns_log bug "Starting to unzip of $tmp_filename to $exdir..."
   catch {exec unzip $tmp_filename -d $exdir}
   ns_log bug "Finished unzipping"
   set l_files [list]
   foreach file [lsort [glob ${exdir}/*]] {
       set file_extension [string tolower [file extension $file]]
       regsub "\." $file_extension "" file_extension
       set photo_id [db_string get_next_object_id "select acs_object_id_seq.nextval from dual"]
       lappend l_files $file $file $file_extension $photo_id
   }
} else {
   set l_files [list $tmp_filename $upload_file $file_extension $photo_id]
}

foreach {tmp_filename upload_file file_extension photo_id} $l_files {
ns_log bug "Starting to add file: $tmp_filename $file_extension $photo_id"
ns_write "Handling $tmp_filename (as $photo_id)...
"

Just insert this bit before set base_n_bytes... and remember to close the foreach loop before set page... in the bottom. Finally, comment out the ad_returnredirect.

Also, you'd need to set up application/x-zip-compressed as an AcceptableUploadMIMETypes in parameters.