sureshp
04-23-2007, 03:08 AM
Hi!
Is it possible to upload a folder in asp.net2.0? If possible, please help me to do this!
Thanks in advance!
Is it possible to upload a folder in asp.net2.0? If possible, please help me to do this!
Thanks in advance!
|
Click to See Complete Forum and Search --> : uploading a folder sureshp 04-23-2007, 03:08 AM Hi! Is it possible to upload a folder in asp.net2.0? If possible, please help me to do this! Thanks in advance! saraahmed 04-24-2007, 03:13 PM hi i hope it will be helpfull at first u can not upload folder in asp.net but u can upload file by: 1. use FileField control "HTML control" then change its properties from HTML tag <input type="file"> add runat="server". 2. add enctype="multipart/form-data" attribute to <form> tag. 3. expand the solution explorer tree -->right click on project name -->add new folder and name it upload . 4. go to c:// directory to give permission on uplaod folder by c:// intpup-->wwwroot-->your project-->upload-->right click--> proberties--> security tab--> add--> choose ASP machine account from box appear-->then check on all permission allowed--> ok. 5.add code to code behind page: * btm_attach_click: event of button u will click on it to after browsing on file will be iploaded by filefield control. * file1 : the name of filefield control. * you can attach to more than one filefield. private void btm_attach_Click(object sender, System.EventArgs e) { //attach to file1 String str1 = File1.PostedFile.FileName.ToString(); int index1 = str1.LastIndexOf("/"); String filename1 = str1.Substring(index1+1); index1 = filename1.LastIndexOf(@"."); String ext1 = filename1.Substring(index1); if(ext1=="jpg") { File1.PostedFile.SaveAs("C:\\intpub\\wwwroot\\your project\\upload"+filename1); } if(ext1=="txt") { File1.PostedFile.SaveAs("C:\\intpub\\wwwroot\\your project\\upload"+filename1); } //attach to file2 String str2 = File2.PostedFile.FileName.ToString(); int index2 = str2.LastIndexOf("/"); String filename2 = str2.Substring(index2+1); index2 = filename2.LastIndexOf(@"."); String ext2 = filename2.Substring(index2); if(ext2=="jpg") { File1.PostedFile.SaveAs("C:\\intpub\\wwwroot\\your project\\upload"+filename2); } if(ext2=="txt") { File1.PostedFile.SaveAs("C:\\intpub\\wwwroot\\your project\\upload"+filename2); } //attach to file3 String str3 = File3.PostedFile.FileName.ToString(); int index3 = str3.LastIndexOf("/"); String filename3 = str3.Substring(index3+1); index3 = filename3.LastIndexOf(@"."); String ext3 = filename3.Substring(index3); if(ext3=="jpg") { File1.PostedFile.SaveAs("C:\\intpub\\wwwroot\\your project\\upload"+filename3); } if(ext3=="txt") { File1.PostedFile.SaveAs("C:\\intpub\\wwwroot\\your project\\upload"+filename3); } } webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |