Image upload problem across browsers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ntombikayise
    New Member
    • Oct 2006
    • 1

    Image upload problem across browsers

    Hi,

    I urgently need help. My code should let a user select an image file for upload, view the image on the browser to be able to set the image size then upload the image. It should also be compatible in IE, Opera and Firefox. Currently everything works well in IE only.

    Problem:
    1) I can't view an image from a local drive in Opera and Firefox. I am aware that Firefox doesn't link local files, so I set user_pref("secu rity.checkloadu ri", false); in user.js (Profiles folder), but it is still not working. i checked on about:config on the browser and the value is set as indicated. Why can't i view my images?
    <img src='c:\misc\ca lc.jpg'>

    2) When trying to access the file chosen by the user, i can only get the filename and not the whole path in Opera and Firefox.
    eg. html code: <input name='userfile' type='file'>

    window.alert(do cument.all.item ('userfile').va lue); returns 'calc.jpg' and not 'c:\misc\calc.j pg'. How do i get the path?

    3) I read that the height and width attributes have been deprecated. how then can i allow my user to set up their sizes if i can only set image sizes in css and not in the html code itself:
    <img src='c:\misc\ca lc.jpg' height='$userHe ight' width='$userWid th'>
    (I'm also using php in mycode)

    i'd really appreciate it if i can get a fast response. thanks.

    Ntombi
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Originally posted by ntombikayise
    1) I can't view an image from a local drive in Opera and Firefox. I am aware that Firefox doesn't link local files, so I set user_pref("secu rity.checkloadu ri", false); in user.js (Profiles folder), but it is still not working. i checked on about:config on the browser and the value is set as indicated. Why can't i view my images?
    <img src='c:\misc\ca lc.jpg'>
    This link should help.

    Originally posted by ntombikayise
    2) When trying to access the file chosen by the user, i can only get the filename and not the whole path in Opera and Firefox.
    eg. html code: <input name='userfile' type='file'>

    window.alert(do cument.all.item ('userfile').va lue); returns 'calc.jpg' and not 'c:\misc\calc.j pg'. How do i get the path?
    Give the input file element an id and access it using document.getEle mentById("userf ile").

    Originally posted by ntombikayise
    3) I read that the height and width attributes have been deprecated. how then can i allow my user to set up their sizes if i can only set image sizes in css and not in the html code itself:
    <img src='c:\misc\ca lc.jpg' height='$userHe ight' width='$userWid th'>
    (I'm also using php in mycode)
    AFAIK height and width are not deprecated. You can set them using JavaScript too, or use text boxes for input to set the image size on the server.

    Comment

    Working...