---
title: "Asp.NET temporary file saving"  
description: "Asp.NET temporary file saving"  
author: "Anonymous User"  
published: 2015-03-28  
updated: 2015-03-28  
canonical: https://www.mindstick.com/forum/23062/asp-dot-net-temporary-file-saving  
category: "asp.net"  
tags: ["c#", "file"]  
reading_time: 1 minute  

---

# Asp.NET temporary file saving

I got a [path](https://www.mindstick.com/articles/44333/4-expert-tips-on-how-to-pick-the-right-career-path) from the [jquery code](https://www.mindstick.com/forum/157821/write-a-jquery-code-that-selects-all-the-checkboxes-in-a-form-when-a-select-all-button-is-clicked) URL.createObjectURL(event.target.files[0]);

It returns something like this : [blob](https://www.mindstick.com/articles/11906/working-with-blob-binary-large-objects):[http](https://www.mindstick.com/blog/217/http-endpoints-in-sql-server-2005-2008)%3A/localhost%3A59105/f7dae0f7-088f-48cf-b446-eeda0bf23705

I [tried to save](https://answers.mindstick.com/qa/45247/what-do-you-think-of-sacking-of-dr-kafeel-who-tried-to-save-children-in-gorakhpur-by-buying-oxygen-himself) this [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) like

```
byte[] data;    using (WebClient
client = new WebClient())    {        data =client.DownloadData("blob:http%3A/localhost%3A59105/f7dae0f7-088f-48cf-b446-eeda0bf23705");    }   
File.WriteAllBytes(@"~/a.jpg", data);
```

But it gives an [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) about the code above:

The [URI](https://www.mindstick.com/interview/271/what-is-the-difference-between-url-and-uri) prefix is not recognized.

How exactly I can [copy](https://www.mindstick.com/forum/161993/explain-the-numpy-array-copy-vs-view-with-example) this file?

Thanks for your suggestions.

## Replies

### Reply by Jayden Bell

1.Create simple GET method

```
[HttpGet]public ActionResult GetFile(){  return View();}
```

2. Create View with @Html.BeginForm helper

```
@using (Html.BeginForm("GetFile","YourController", FormMethod.Post, { enctype = "multipart/form-data" })){<input type="file" id="fileup" name="file"/><input type="submit" value="Send">}
```

Rembember to use name attribute and overloaded version of Html.BeginForm()

3.Get data in Backend

```
[HttpPost]public ActionResult GetFile(HttpPostedFileBase file){  if (file != null && file.ContentLength > 0)  {     var fileName =Path.GetFileName(file.FileName);     var filePath =Path.Combine(Server.MapPath("~/Temp/"), fileName);    
file.SaveAs(path);  }   return RedirectToAction("Success");}
```

Name in html attribute must have same name as HttpPostedFileBase.


---

Original Source: https://www.mindstick.com/forum/23062/asp-dot-net-temporary-file-saving

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
