Image Upload with Preview and Delete

前端 未结 6 1345
情话喂你
情话喂你 2020-12-14 13:21

Have the followig questions and need answers regarding the following script that will Preview a Photo before upload. The script is from http://jsbin.com/uboqu3/edit#javascri

6条回答
  •  伪装坚强ぢ
    2020-12-14 13:54

    Demo

    Tested on several browsers, Chrome, Fx, Safari 6 (could someone test 5?)

    Works on my IE8 on XP without any changes in settings but as @Gunasekaran mentions later on this page you may need to

    Open Tools->internet option-> security tab-> custom level - locate the setting "Include local directory path when uploading files to a server" and click on Enable.

    
    
    
    
    Image preview
    
    
    
    
    
    
    

    your image [X]

    Looks like this in IE8 on XP:

    Example

    A newer method is createObjectURL which I have not implemented

    Update You will need to add an onclick to clear the file input if you want to allow the user to select the same image twice (onchange does not trigger then)

    HTML input file selection event not firing upon selecting the same file

提交回复
热议问题