Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. preview a picture from my hard disk before upload it

preview a picture from my hard disk before upload it

Scheduled Pinned Locked Moved ASP.NET
helpsysadminquestion
15 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N N a v a n e e t h

    ayeleteric wrote:

    C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg

    In javascript \ will be escaped. So use \\ instead of \. I think this will solve your problem.


    My Website | Ask smart questions

    A Offline
    A Offline
    ayeleteric
    wrote on last edited by
    #6

    Thank you but it doesn't work too.

    Eric H.

    1 Reply Last reply
    0
    • E enjoycrack

      Hi Eric, try this link http://javascript.internet.com/forms/image-upload-preview.html[^] << >>

      8x Solutions Ltd

      A Offline
      A Offline
      ayeleteric
      wrote on last edited by
      #7

      Thank you but this is the source that make me problem (see my first post)

      Eric H.

      E 1 Reply Last reply
      0
      • A ayeleteric

        Thank you but this is the source that make me problem (see my first post)

        Eric H.

        E Offline
        E Offline
        enjoycrack
        wrote on last edited by
        #8

        what problem you got with the example script? any js error? you try to run in FF to see more detail with js error.. << >>

        8x Solutions Ltd

        A 1 Reply Last reply
        0
        • E enjoycrack

          what problem you got with the example script? any js error? you try to run in FF to see more detail with js error.. << >>

          8x Solutions Ltd

          A Offline
          A Offline
          ayeleteric
          wrote on last edited by
          #9
          1. What is FF 2) I do not get any error but when I am selecting a picture from my hard disk using the dialog box, no picture is previewed Thank you

          Eric H.

          E 2 Replies Last reply
          0
          • A ayeleteric
            1. What is FF 2) I do not get any error but when I am selecting a picture from my hard disk using the dialog box, no picture is previewed Thank you

            Eric H.

            E Offline
            E Offline
            enjoycrack
            wrote on last edited by
            #10

            FF is Firefox browser... << >>

            8x Solutions Ltd

            1 Reply Last reply
            0
            • A ayeleteric
              1. What is FF 2) I do not get any error but when I am selecting a picture from my hard disk using the dialog box, no picture is previewed Thank you

              Eric H.

              E Offline
              E Offline
              enjoycrack
              wrote on last edited by
              #11

              As i used this before..and it's working well..so can you send me your html page to see what problem? << >>

              8x Solutions Ltd

              A 1 Reply Last reply
              0
              • E enjoycrack

                As i used this before..and it's working well..so can you send me your html page to see what problem? << >>

                8x Solutions Ltd

                A Offline
                A Offline
                ayeleteric
                wrote on last edited by
                #12

                Thank you for your help, You can copy the code from my first post

                Eric H.

                G 1 Reply Last reply
                0
                • A ayeleteric

                  Thank you for your help, You can copy the code from my first post

                  Eric H.

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #13

                  As you didn't use the "Ignore HTML" option when you posted the code, he can't use it. There are several parts of the code that doesn't show up in the message.

                  --- single minded; short sighted; long gone;

                  A 2 Replies Last reply
                  0
                  • G Guffa

                    As you didn't use the "Ignore HTML" option when you posted the code, he can't use it. There are several parts of the code that doesn't show up in the message.

                    --- single minded; short sighted; long gone;

                    A Offline
                    A Offline
                    ayeleteric
                    wrote on last edited by
                    #14

                    Thank you Guffa, Here is my code: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> // width to resize large images to var maxWidth=100; // height to resize large images to var maxHeight=100; // valid file types var fileTypes=["bmp","gif","png","jpg","jpeg"]; // the id of the preview image tag var outImage="previewField"; // what to display when the image is not valid var defaultPic="box_icons.jpg"; /***** DO NOT EDIT BELOW *****/ function preview(what) { var source=what.value; var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase(); for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break; globalPic=new Image(); if (i<fileTypes.length) globalPic.src=source; else { globalPic.src=defaultPic; alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", ")); } setTimeout("applyChanges()",200); } var globalPic; function applyChanges() { var field=document.getElementById(outImage); var x=parseInt(globalPic.width); var y=parseInt(globalPic.height); if (x>maxWidth) { y*=maxWidth/x; x=maxWidth; } if (y>maxHeight) { x*=maxHeight/y; y=maxHeight; } field.style.display=(x<1 || y<1)?"none":""; field.src=globalPic.src; field.width=x; field.height=y; } // End -->

                    Test it by locating a valid file on your hard drive:

                    Eric H.

                    1 Reply Last reply
                    0
                    • G Guffa

                      As you didn't use the "Ignore HTML" option when you posted the code, he can't use it. There are several parts of the code that doesn't show up in the message.

                      --- single minded; short sighted; long gone;

                      A Offline
                      A Offline
                      ayeleteric
                      wrote on last edited by
                      #15

                      As I wrote upstair, I simplify the problem to a short code. Can you try to help me on this code. I think it will help me to the big one too. The problem is that I do not see the picture. // <!CDATA[ function Button1_onclick() { document.getElementById("img1").src="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg" } // ]]>

                      Thank you, Eric H.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups