removing white space and non file characters

Upload core product.
Post Reply
dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

removing white space and non file characters

Post by dj_hands3 »

Just trying to fool proof my upload page and upon tests i had trouble uploading a file name like this:

Cartier B2B Spin E B Featuring Sharkie P, Kie, Hyperactive, CKP & Sparks2.mp3

With the above i would need to remove white spaces and ',' and replace with an underscore is there a way to do this and if so could someone please show an example param value?

Also is this an immediate action as I also have a exteneted javascript that calls the uploading file name to a hidden input on the page within a form to forward to a database.

Thanks.

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: removing white space and non file characters

Post by support »

You remove non-ascii + some specific characters, you can use template parameter with a regular expression. Try the following one and let me know if it helps:
<PARAM NAME="template" VALUE=":regex=[^a-zA-Z0-9_\\-\\.]:_:">

dj_hands3
Posts: 10
Joined: Tue Mar 03, 2009 9:41 pm

Re: removing white space and non file characters

Post by dj_hands3 »

Sorry I tried this and no luck,

Code: Select all

<!--
var _info = navigator.userAgent;
var _ns = false;
var _ns6 = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
if (_info.indexOf("Opera") > 0) _ie = false;
var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
if (_ie == true) {
  document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="250" HEIGHT="300" NAME="fileupload" codebase="http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0">');
}
else if (_ns == true && _ns6 == false) {
  // BEGIN: Update parameters below for NETSCAPE 3.x and 4.x support.
  document.write('<EMBED ');
  document.write('type="application/x-java-applet;version=1.4" ');
  document.write('CODE="jfileupload.upload.client.JSMApplet.class" ');
  document.write('JAVA_CODEBASE="./" ');
  document.write('ARCHIVE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar,lib/jsapi.jar" ');
  document.write('NAME="fileupload" ');
  document.write('WIDTH="250" ');
  document.write('HEIGHT="250" ');
  document.write('mode="ftp" ');
  document.write('regfile="license.oxw" ');
  document.write('scriptable=true ');
  document.write('mayscript=true ');
  document.write('overwrite="timerename" ');
  document.write('template=":regex=[^a-zA-Z0-9_\\-\\.]:_:" ');
  document.write('resources="i18n" ');
  document.write('whitelist="*.mp3" ');
  document.write('param5="account" ');
  document.write('value5="htdocs/mixes/" ');
  document.writeln('pluginspage="http://java.sun.com/products/plugin/index.html#download"><NOEMBED>');
  // END
}
else {
  document.writeln('<APPLET CODE="jfileupload.upload.client.JSMApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar,lib/jsapi.jar" WIDTH="250" HEIGHT="300" NAME="fileupload" MAYSCRIPT>');
}
// BEGIN: Update parameters below for INTERNET EXPLORER, FIREFOX, SAFARI, OPERA, MOZILLA, NETSCAPE 6+ support.
document.writeln('<PARAM NAME=CODE VALUE="jfileupload.upload.client.JSMApplet.class">');
document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
document.writeln('<PARAM NAME=ARCHIVE VALUE="lib/jfileupload.jar,lib/ftpimpl.jar,lib/cnet.jar,lib/clogging.jar,lib/jsapi.jar">');
document.writeln('<PARAM NAME=NAME VALUE="fileupload">');
document.writeln('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
document.writeln('<PARAM NAME="regfile" VALUE="license.oxw">');
document.writeln('<PARAM NAME="scriptable" VALUE="true">');
document.writeln('<PARAM NAME="mayscript" VALUE="true">');
document.writeln('<PARAM NAME="overwrite" VALUE="timerename">');
document.writeln('<PARAM NAME="template" VALUE=":regex=[^a-zA-Z0-9_\\-\\.]:_:">');
document.writeln('<PARAM NAME="mode" VALUE="ftp">');
document.writeln('<PARAM NAME="resources" VALUE="i18n">');
document.writeln('<PARAM NAME="whitelist" VALUE="*.mp3">');
document.writeln('<PARAM NAME="param5" value="account">');
document.writeln('<PARAM NAME="value5" value="htdocs/mixes/">');
// END
if (_ie == true) {
  document.writeln('</OBJECT>');
}
else if (_ns == true && _ns6 == false) {
  document.writeln('</NOEMBED></EMBED>');
}
else {
  document.writeln('</APPLET>');
}
//-->

User avatar
support
Posts: 1503
Joined: Sun Jan 27, 2008 6:19 pm

Re: removing white space and non file characters

Post by support »

What behavior do you have ? You could try to remove the "overwrite" parameter ?

Post Reply