How to create Music file upload in asp.net? [Resolved]

Posted by Chandru_ra under Regular Expressions on 4/20/2011 | Points: 10 | Views : 4479 | Status : [Member] | Replies : 4
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:\\

chandru


Responses

Posted by: Ndebata on: 4/20/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi

Please check ASP.net has write access to that partcular folder path.Other wise add permission for the account running asp.net.
And to handle filesize in the web.config
under <system.web>
add
<httpRuntime maxRequestLength="200000" />


Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 4/20/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Chandru,

Could you please respond what error you are getting?
Default size allowed for file upload is 4MB.
In case if you trying to upload a file having size more than 4 MB, you need to change the setting.

Thanks,
Debata

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 4/20/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Chandru , .

i think u write code may be generate error on this line


string folderpath = "Audio";

please correct on Ur folder address Like

string folderpath = "~/Audio";

Best Regard's
Prabhakar

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandru_ra on: 4/20/2011 [Member] Starter | Points: 25

Up
0
Down
hi, friends..
The connection was reset

The connection to the server was reset while the page was loading.

* The site could be temporarily unavailable or too busy. Try again in a few
moments.

* If you are unable to load any pages, check your computer's network
connection.

* If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.


Thanks in advance









chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response