...

View Full Version : Path name on a MAC?



tdavis
10-13-2006, 07:41 PM
I wrote the following to make sure that the images that my script will be uploading do not have embedded blanks. It works fine, but not on a MAC. I did not discover this because I do not have a MAC. but the person that I wrote this for does, and she cant use it because of this problem. I suspect it has something to do with me splitting the path up with the backslashes. Is it possible to make this work with a MAC?

Thanks,
-tdavis

var elmArray = document.upload.elements;
for (var i=elmArray.length-1;i>-1;i--){
if (elmArray[i].type == "file" && elmArray[i].value != "") {
var text = elmArray[i].value;
var spit = text.split("\\");
//alert(text);
for (x in spit)
{
count++;
}
text = spit[x];
for(c=0;c<text.length;c++) {
if(text.charAt(c)==' ') {
blerrors++;
elmArray[i].className = "inputreq";
}}}}

Kravvitz
10-13-2006, 11:43 PM
Microsoft operating systems use back-slashes in paths. Other operating systems, including UNIX and Linux variants (e.g. MacOSX, RedHat, Suse), use forward-slashes.

Try this.

var spit = text.split(/[\/\\]/);

tdavis
10-14-2006, 09:05 PM
I am told that this worked (I dont have the MAC)...
Thank you very much!

Kravvitz
10-14-2006, 09:07 PM
You're welcome :)

It's so much easier to do web programming when you know how to use RegExp and some have background knowledge of how file systems and the WWW work. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum