.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Music file upload in asp.net

Posted By: chandru     Posted Date: April 19, 2011    Points:5   Category :ASP.Net
hi, friends

i have used in this code. but this support to local. not support to FTP server side pls help this

cs coding:

protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strCS);
con.Open();
SqlCommand cmd = new SqlCommand("Sp_Audio", con);
cmd.CommandType = CommandType.StoredProcedure;


cmd.Parameters.AddWithValue("@song", FileUpload1.FileName);

cmd.ExecuteNonQuery();

if (FileUpload1.HasFile)
{

string fname = FileUpload1.FileName.ToString();

string folderpath = "Audio";

string path = HttpContext.Current.Server.MapPath(folderpath);



FileUpload1.PostedFile.SaveAs(path + "\\" + fname);

Response.Write("file upload sucessfully");

Response.Redirect("default3.aspx?song="+FileUpload1.FileName);
}
}

design code:

<table>
<tr><td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td></tr>
<tr>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<tr><td>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /></td></tr>
</table>

server error: the connection was reset this error displayed in http:\\

Responses
Author: Sunil Yadav       [Moderator]      
Posted Date: May 27, 2011     Points: 20   

Hi,

Try setting the maxRequestLength and executionTimeout in your web.config.

<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600"/>
</system.web>


Also the above code is vulnerable to File upload vulnerability.
This allows an attacker to upload malicious files.
You can refer this link https://www.owasp.org/index.php/Unrestricted_File_Upload

Hope this helps.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend