开发者

File upload control in ASP.NET

开发者 https://www.devze.com 2023-01-10 23:04 出处:网络
i am using file upload control in ASP.NET for uploading images. In my form there are two buttons.one for assigning criteria which redirects to other form and other for submitting form.

i am using file upload control in ASP.NET for uploading images. In my form there are two buttons.one for assigning criteria which redirects to other form and other for submitting form. After assigning criteria only the user has to use submit button.

My problem is when is upload image and click on AssignCriteria button and return back to original page,the upload co开发者_如何学JAVAntrol is getting blank. How to keep that upload image control value in that textbox even if we redirected to other page and come back.


<asp:FileUpload runat="server" ID="uploadStatement" />
<asp:Button runat="server" Text="Upload" OnClick="cmdUpload_Click" />

Next code uploads selected file to Temp folder on the server, in my case - parses it and deletes the file.

    protected void cmdUpload_Click(object sender, EventArgs e)
    {
        var fileName = Server.MapPath(Path.Combine("Temp", String.Concat(Guid.NewGuid().ToString(), Path.GetExtension(uploadStatement.FileName))));
        try
        {
            uploadStatement.SaveAs(fileName);

            // parse file
        }
        finally
        {
            File.Delete(fileName);
        }
    }


Since any manipulation with the "input type='file'" element is a serious security threat I am afraid there is no way to do this.

Have you considered using of some AJAX overlay "dialog"?

0

精彩评论

暂无评论...
验证码 换一张
取 消