FileUpload control.

Discussion in 'ASP .Net' started by Eric, Dec 26, 2005.

  1. Eric

    Eric Guest

    I'm using the fileuploadcontrol for the user to select a file, in this case
    a image file.
    I would like to see the little preview image to be shown right after
    selection, but there seems to be no event from the fileupload control.
    To by-pass this I let the user click on a linkbutton to show the preview,
    but when the page comes back after the postback, the fileuploadcontrol is
    empty again.

    Is there an update to this control, giving more events?
    Is there a third party control, better then the one shipped with vs2005?
    Is there a way to create these events for the fileuploadcontrol?

    rg,
    Eric
    Eric, Dec 26, 2005
    #1
    1. Advertising

  2. Eric

    intrader Guest

    On Mon, 26 Dec 2005 20:38:28 +0100, Eric wrote:

    > I'm using the fileuploadcontrol for the user to select a file, in this case
    > a image file.
    > I would like to see the little preview image to be shown right after
    > selection, but there seems to be no event from the fileupload control.
    > To by-pass this I let the user click on a linkbutton to show the preview,
    > but when the page comes back after the postback, the fileuploadcontrol is
    > empty again.
    >
    > Is there an update to this control, giving more events?
    > Is there a third party control, better then the one shipped with vs2005?
    > Is there a way to create these events for the fileuploadcontrol?
    >
    > rg,
    > Eric

    Once the file is at the server, you can have the server render an
    image to the client in thumbnail size width/height.
    intrader, Dec 27, 2005
    #2
    1. Advertising

  3. Eric

    Guest

    First of all, excuse my poor english.

    I don't think that is possible, let me explain why. Through Javascript
    you cannot access the local filesystem, perhaps setting the IE security
    to lowest, but I don't think it could work. As intrader has noticed,
    that can be accomplished once the file is in the web server, it is the
    best way.

    The following code does NOT work.

    <script type="text/javascript" language="javascript">
    function cargarImagenServer(){
    Imagen.src=fileUploader1.value;
    }
    </script>
    <img id="Imagen" alt="Imagen A mostrar" src="" />
    <asp:FileUpload runat="server" onclick="cargarImagenServer();"
    ID="fileUploader1" />
    , Dec 27, 2005
    #3
  4. Eric

    PalehorseX

    Joined:
    Aug 4, 2009
    Messages:
    1
    This works for me:

    HTML:
    <script type="text/javascript">
         function previewImg(path, img) {
              imgPrev = document.images[img];
              imgPrev.src = path;
         }
    </script>
    
    HTML:
    <asp:FileUpload runat="server" ID="uploadImage"  onchange="previewImg(this.value, 'imgPreview');" />
    <br />
    <asp:Image ID="imgPreview" name="imgPreviewModify" runat="server" />
    
    PalehorseX, Aug 4, 2009
    #4
  5. Eric

    Ankho

    Joined:
    Nov 3, 2009
    Messages:
    1
    Not Working

    Hello,

    It's not working with me can anyone plz help...
    The src of the image is changing but the page isnt refreshing so that the image can load again with the other src...

    Thank you,

    Anthony
    Ankho, Nov 3, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Uncle Ben

    ASP.NET 2.0 FileUpload control

    Uncle Ben, Mar 23, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,780
    Bruce Barker
    Mar 23, 2005
  2. VB Programmer

    How check filesize using FileUpload control?

    VB Programmer, Jan 18, 2006, in forum: ASP .Net
    Replies:
    11
    Views:
    20,376
  3. Nathan Sokalski
    Replies:
    1
    Views:
    740
    Mark Rae
    Jan 11, 2007
  4. eamon

    FileUpload Control & Image Control

    eamon, Aug 4, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    200
    eamon
    Aug 4, 2005
  5. Nathan Sokalski
    Replies:
    0
    Views:
    249
    Nathan Sokalski
    Jan 11, 2007
Loading...

Share This Page