asp.net slickupload use method (File upload) _ Practical skills

Source: Internet
Author: User
Add in Web.config:
<add name= "Httpuploadmodule" type= "Krystalware.SlickUpload.HttpUploadModule, krystalware.slickupload"/>
2, add a reference to the Krystalware.SlickUpload.DLL in the project.
3, put the control on the page: HtmlInputFile fileupload;
4, after the code is as follows:
Copy Code code as follows:

private void Redirecttonewupload ()
{
Response.Redirect ("photoinfo.aspx?uploadid=" Guid.NewGuid (). ToString () "&action=" Strviewtype "&id=" btsid);
}
private void Page_Load (object sender, System.EventArgs e)
{
...
Uploadedfilecollection parts = Httpuploadmodule.getuploadedfiles ();
if (request.querystring["uploadid"] = = null)
Redirecttonewupload ();
...
}
private void Btupload_click (object sender, System.EventArgs e)
{
Uploadedfilecollection parts = Httpuploadmodule.getuploadedfiles ();
String uppath = system.configuration.configurationsettings.appsettings["Uploadpath"];
Try
{
if (Parts!= null)
{
foreach (UploadedFile part in parts)
{
if (part. contentlength==0)
Return
if (File.exists (Uppath part). ClientName))
{
File.delete (Uppath part. ClientName);
}
Part. SaveAs (Uppath part. ClientName);
byte[] Filebytearray = new Byte[part. ContentLength]; Image file temporary storage byte array
FileStream fs = new FileStream (Uppath part. ClientName, FileMode.Open);
Fs. Read (Filebytearray,0,convert.toint32 (part. ContentLength));
Fs. Close ();
File.delete (Uppath part. ClientName);
Use Filebytearray to save the resulting data
}
Redirecttonewupload ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.