C1Uploadcontrol question.

Posted by: jung on 10 September 2017, 12:01 pm EST

  • Posted 10 September 2017, 12:01 pm EST

    Hi
    I am using C1Upload.
    if i want to save file to other folder, what function can i use?
    for example Fileupload control provide 'saveas function'.
  • Marked as Answer

    Replied 10 September 2017, 12:01 pm EST

    Hello,

    With C1Upload you may upload the file to server folder. To configure the path where you want to upload the file you may set the path in Handler. Here is the example code to set the upload path in Handler:

    public class FileUploader : IHttpHandler
    {
    public void ProcessRequest(HttpContext context)
    {
    // folder to save file on server
    string sDirectory = HttpContext.Current.Server.MapPath("~/Temp");
    if (!Directory.Exists(sDirectory))
    {
    Directory.CreateDirectory(sDirectory);
    }

    var request = context.Request;
    var requestType = request.Headers["Wijmo-RequestType"];
    if (!String.IsNullOrEmpty(requestType) && requestType == "XMLHttpRequest")
    {
    var fileName = request.Headers["Wijmo-FileName"];
    using (FileStream fs = new FileStream(sDirectory + "\\" + context.Server.UrlDecode(fileName), FileMode.Create))
    {
    var inputStream = context.Request.InputStream;
    byte[] bytes = new byte[(int)inputStream.Length];
    inputStream.Read(bytes, 0, (int)inputStream.Length);
    fs.Write(bytes, 0, bytes.Length);
    fs.Close();
    }
    }

    }
    public bool IsReusable
    {

    get
    {

    return true;

    }

    }

    }


    Thanks,
    Deepak Sharma
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels