View Full Version : Path name on a MAC?

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?


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("\\");
for (x in spit)
text = spit[x];
for(c=0;c<text.length;c++) {
if(text.charAt(c)==' ') {
elmArray[i].className = "inputreq";

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(/[\/\\]/);

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

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