Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am using "uploadify" plugin in my asp.net page to upload my document. now the problem is that i am using "AttachedFile" folder to take upload document and it is in the root directory of project and and my webpage where i am using plugin is within folder within folder,and all part is working well but the upload document is saving in the same folder where i have created my webpage my jquery code is like this
JavaScript
<script type="text/javascript">
       $(window).load(
       function () {
           $("#<%=FileUpload1.ClientID %>").fileUpload({
               'uploader': '../../script/uploader.swf',
               'cancelImg': '../../images/cancel.png',
               'buttonText': 'Browse',
               'script': 'Upload.ashx',
               'folder': '~/AttachedFile/',
               'fileDesc': 'Image Files',
               'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
               'multi': true,
               'auto': false
           });
       }
       );
   </script>

help me to overcome from this problem
Thank You :)
Posted
Comments
Kornfeld Eliyahu Peter 14-Jan-14 3:19am    
'~/AttachedFile/' - it's something that client side does not understand. '~' has meaning in the server (asp) only, you should use something like '../AttachedFile' (relative to the page used to upload)...
Amit Kumar143 14-Jan-14 4:15am    
yes i replace ~ with "../../AttachedFile" but it not working yet again file is saving in the same folder where i created the webpage
Suk@nta 14-Jan-14 4:01am    
yes replace ~/(it will not work for javascript) with ../
Amit Kumar143 14-Jan-14 4:14am    
yes i replace ~ with "../../AttachedFile" but it not working yet again file is saving in the same folder where i created the webpage
Amit Kumar143 14-Jan-14 4:14am    
yes i replace ~ with "../../AttachedFile" but it not working yet again file is saving in the same folder where i created the webpage

1 solution

In the code behind use the following one:
C#
public void ProcessRequest (HttpContext context) {
       HttpPostedFile fileToUpload = context.Request.Files["Filedata"];
       string pathToSave = HttpContext.Current.Server.MapPath("~/AttachedFile/") + fileToUpload.FileName;
       fileToUpload.SaveAs(pathToSave);
   }
 
Share this answer
 

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