XUpload - multiple file upload each with custom parameters

Message
Author
giorrrgio
Posts: 8
Joined: Aug 04, 2008 11:11 am

multiple file upload each with custom parameters

#1 Postby giorrrgio » Aug 04, 2008 1:41 pm

Hi there,
I've an upload form with which users can upload a file, specyifing some custom fields.
Since I have to post all this data with ajax calls, I followed some hints on this forum and modified this way upload.cgi:

Code: Select all

print"<HTML><BODY><Script>";
for my $f (@files)
{
	 print "window.top.window.updateUploadDiv('$f->{file_name}' , '$f->{file_name_orig}' , '$f->{file_size2}' , '$f->{file_size}' , '$f->{file_status}');";
}
print"</Script></BODY></HTML>";
Now my issues:
I'd like to pass all the custom fields to that javascript function, in addition to other file related data.
I saw something related to @har variable, but I'm not familiar with perl, so please help :-)
Second issue: if I want to make this form multiupload, how can I manage separate custom fields for each file I upload? (E.G. if user uploads 4 songs, I need him to specify title and genre for each song in separate fields). It seems that custom fields are treated without the possibility to do what i need.
I'm using the pro version.
Thanks

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#2 Postby PilgrimX182 » Aug 06, 2008 1:18 pm

1) What file-related fields fo u need more?

2) I think this is pretty easy: in xupload.js clone this part of code:

Code: Select all

        if(enable_file_descr==1)
        {
            var new_row_descr = document.createElement( 'input' );
    		new_row_descr.type = 'text';
            new_row_descr.name = element.name+'_descr';
            new_row_descr.className='fdescr';
            new_row_descr.setAttribute('maxlength', 128);
            var div2 = document.createElement( 'div' );
                div2.className = 'xdescr';
                div2.appendChild( document.createTextNode('Description:') );
            div2.appendChild( new_row_descr );
            new_row.appendChild( div2 );
        }
and replace there in new code '_descr' to e.g. '_title', 'Description:' to e.g. 'Title:'

Then in upload.cgi after

Code: Select all

   $fhash->{file_descr} = $cg->param("$k\_descr");
add

Code: Select all

   $fhash->{file_title} = $cg->param("$k\_title");
and after

Code: Select all

'$f->{file_status}'
add

Code: Select all

,'$f->{file_title}'
to send it back to your JS function

giorrrgio
Posts: 8
Joined: Aug 04, 2008 11:11 am

#3 Postby giorrrgio » Sep 22, 2008 9:25 am

Hi,
your solution is good but I've found a problem with special characters.
My website uses utf-8 as charset and if put special characters in the title field the upload freezes at 100%.
Any idea?

Thanks

User avatar
PilgrimX182
Posts: 2186
Joined: Mar 22, 2006 1:39 pm

#4 Postby PilgrimX182 » Sep 22, 2008 9:53 am

No idea actually. Try to disable email notifications first in config. Then check error_log, make hidden xupload iframe visible, probablt some errors there.