Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#ASP.NET
while uploading images the path given to store images is not found.
Posted 24-Dec-12 18:50pm
Comments
Krunal Rohit at 25-Dec-12 0:51am
   
Provide your code...
hiphopper0123 at 25-Dec-12 1:14am
   
if u expect help then provide your code
Oleksandr Kulchytskyi at 25-Dec-12 3:39am
   
Are envisioning to expose any code to community?)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You should provide your code and explain more about your problem.
ok, I can guess that you are talking about image path of ASP.NET Client side. you cant find full path of any uploaded document. So you can encode your uploaded image on client side and also can view the image, after postback on button click get the encode (base64) data to binary and save to database or store image on application server.
 
follow this given code:
 
<form id="form1" runat="server">
    <div>
        <asp:Image ID="imgEmployee"  runat="server" ImageUrl="" Width="100px"
                    Height="120px" />
 
        <script type="text/javascript">
            function handleFileSelect(evt) {
 
                var fileUpload = document.getElementById('<%=photoUpload.ClientID%>');
                var imgEmployee = document.getElementById('<%=imgEmployee.ClientID%>');
 
                var files = evt.target.files; // FileList object
                // Loop through the FileList and render image files as thumbnails.
                for (var i = 0, f; f = files[i]; i++) {
 
                    // Only process image files.
                    if (!f.type.match('image.*')) {
                        continue;
                    }
                    var reader = new FileReader();
                    var base64Data;
 
                    reader.onload = (function (theFile) {
                        return function (e) {
                            // Render thumbnail.
                            var span = document.createElement('span');
 
                            base64Data = e.target.result;
                            var fileSize = base64Data.length;
                            var IndexData = base64Data.indexOf('base64,');
                            var fileName = escape(theFile.name);
                            imgEmployee.src = base64Data;
 

                        };
                    })(f);
                    // Read in the image file as a data URL.
                    reader.readAsDataURL(f);
                }
            }
 

 

 
        </script>
        <div>
 
<asp:FileUpload runat="server" ID="photoUpload" TabIndex="7"  onchange="handleFileSelect(event)"   />
 

        </div>
 
    </div>
    </form>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 756
1 OriginalGriff 452
2 Tadit Dash 350
3 sanket saxena 329
4 Peter Leow 228
0 Sergey Alexandrovich Kryukov 11,890
1 OriginalGriff 7,335
2 Peter Leow 5,003
3 Abhinav S 3,943
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web03 | 2.8.140421.2 | Last Updated 25 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid