XUpload - Making file upload optional

Message
Author
jimrws
Posts: 21
Joined: Feb 05, 2008 8:29 am

Making file upload optional

#1 Postby jimrws » Feb 05, 2008 8:34 am

Hi,

Bit of an odd request for a file upload application but I'm wondering if its possible to make the file upload field optional.

Recently purchased Xupload to handle the web forms on my company website but its not just being used for file uploading as the forms can just be simple customer enquiries too. Not all users will want to, or need to upload a file, so I'm wondering if its possible to make it optional some how?

Thanks for any help.

Jim.

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

#2 Postby PilgrimX182 » Feb 05, 2008 8:41 am

It is possiblee, only need to disable No Files validation:
in upload.cgi comment with '#' these lines:

Code: Select all

if($#files==-1)
{
   &lmsg("ERROR: No files uploaded");
   sleep 2;
   &DelData($temp_dir);
   &xmessage("ERROR: No files uploaded");
}
and in xupload.js comment with '//' this line:

Code: Select all

if(NF==0){alert('Select at least one file to upload');return false;};
should work now even without files.

jimrws
Posts: 21
Joined: Feb 05, 2008 8:29 am

#3 Postby jimrws » Feb 05, 2008 8:47 am

Excellent, that worked, thanks.

Thanks for the quick reply too. :wink:

dbcurrin
Posts: 2
Joined: Feb 14, 2008 11:37 pm

#4 Postby dbcurrin » Feb 15, 2008 8:21 pm

Hi there,

I require this option too - making file uploads optional as I'm integrating this with another form.

I've followed these instructions which work fine bit one thing ->

How to stop the progress bar from appearing if no files are selected? I no longer receive a message telling me to choose a file but the progress bar appears all the same.

I'm using an inline bar by the way.

I've had a look at the openStatusWindow() function in upload.js but I couldn't see any easy way of making the show / hide call conditional on whether a file was being uploaded or not.

Am I missing something obvious?

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

#5 Postby PilgrimX182 » Feb 18, 2008 7:28 am

In xupload.js find

Code: Select all

setTimeout("openStatusWindow()",500);
and replace with

Code: Select all

if(NF>0){setTimeout("openStatusWindow()",500);}

dbcurrin
Posts: 2
Joined: Feb 14, 2008 11:37 pm

#6 Postby dbcurrin » Feb 18, 2008 11:02 am

Great! Many thanks for that.