views:

14

answers:

1

hi

 var file_upload=document.getElementById('picture-upload').value;

The code returns diffrent values in two browsers.

in firefox,ie returns 'filename.ext' example: test.jpg

but in opera returns 'fullpath\filename.ext example:C:\fake_path\test.jpg

Is any one knows the problem

+1  A: 

IE6 will also give you a full path, while newer browsers only give the file name. It's for security.

I would check for back or forward slashes in the name and if the exist, strip off the path.

if(/\\/.test(value)){
    value = value.split("\")[value.split("\").length-1];
}else 
if(/\//.test(value)){
    value = value.split("/")[value.split("/").length-1];
}

(that code could probably be tightened up)

mwilcox
thanks. but file_upload.replace(/^.*\\/, '') works fine for me
Paniyar