Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Under the solution explorer i created folder name photos then i add photo programatically...
but from environment i can't see the photos inside the folder but when i open the folder it' s there what is the problem i cant understand.


i am using ajax photo uploader because of this problem upload photo not displaying



when i click the menu show all files on top of object explorer i can find the photo in white color

i need help.....
Posted
Comments
Ramug10 5-Mar-14 8:25am    
show me your code

C#
Asynchronous file upload :

<asp:asyncfileupload id="btnUpload" runat="server" xmlns:asp="#unknown">
                        onuploadedcomplete="btnUpload_UploadedComplete" UploaderStyle="Modern" 
                        CompleteBackColor="White" UploadingBackColor="#CCFFFF"
                            ThrobberID="imgLoader" OnClientUploadComplete="uploadComplete" 
                        OnClientUploadStarted = "uploadStarted"  Width="120px" 
                        ClientIDMode="Static" CssClass="FileUploadWidth" FailedValidation="False"
                         />

 protected void btnUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            try
            {
                File.Delete(string.Format(@"{0}\{1}", Server.MapPath(this.UploadFolderPath), "Test.jpg"));
                filename = System.IO.Path.GetExtension(btnUpload.PostedFile.FileName).ToString();
                btnUpload.SaveAs(Server.MapPath(this.UploadFolderPath) + "Test" + filename);
                imgDisplay.Src = this.UploadFolderPath + "Test" + filename;
            }


            catch (Exception ex)
            {

            }

        }


javascript 

<script type = "text/javascript">
     function uploadStarted() {
         $get("imgDisplay").style.display = "none";
     }
     function uploadComplete(sender, args) {
         var imgDisplay = $get("imgDisplay");
         imgDisplay.src = "images/loader.gif";
         imgDisplay.style.cssText = "";
         var img = new Image();
         img.onload = function () {
             imgLoader.style.cssText = "height:171px;width:150px";
             imgLoader.src = img.src;


         };
         var fileName = "";
         fileName = args.get_fileName();
         var fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);

         img.src = "<%=ResolveUrl(filename) %>" + "Test." + fileExtension;
     }

    </script>
</asp:asyncfileupload>
 
Share this answer
 
Ya Got the problem i assaign for filename again the path in codebehind

public string filename = "~/Photos.jpg";

mgDisplay.Src = this.UploadFolderPath + "Test" + filename;

but still one problem occur...it display the photos but after the refreshing only the uploaded photos are displaying...
 
Share this answer
 
Right click -> Include in project.
 
Share this answer
 
Comments
Mohammed Shamsheer 5-Mar-14 23:36pm    
Ya i did your solution and now photo is showing ...but the photo's not displaying on btowser...now also...
dan!sh 5-Mar-14 23:44pm    
Edit your question with code you are using.
Mohammed Shamsheer 6-Mar-14 0:00am    
i posted the code above....

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900