This is a migrated thread and some comments may be shown as answers.

Changing Temp Folder location of RadAsyncUpload Dynamically

4 Answers 271 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anil
Top achievements
Rank 1
Anil asked on 04 Dec 2013, 08:28 PM
Hi,

I have a requirement where I will be using asyncupload in a pop up window in gridview. I need to save attachments added for each row in a temp folder with someUniqueID I have. And when user click on Save button outside the grid, I will be moving all these files to permanent location. The issue is with modifying temporary folder location dynamically. I want to change the temp folder location when I bring pop-up window by clicking on a button in a row. I do not want to move those files to permanent location until user clicks on save button that is outside grid. I am using radgrid with soma static columns and some dynamic columns.


Thanks,
Anil

4 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 06 Dec 2013, 05:13 PM
Hi Anil,

The files that are saved into the temporary folder can not get mixed up. Each file in temporary folder has a unique name, which is formed by the original name and the current time stamp. For example:
if you upload "telerik.png" it will be uploaded to temporary folder with name: "1386335690530telerik.png". This means that you can upload one file from two different uploads and there will be no problem to save it from both uploads.

Please find the attached sample.

Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Anil
Top achievements
Rank 1
answered on 06 Dec 2013, 09:06 PM

Well..

Let me explain again.

My Grid will have testcases listed in each row with a testcaseid. I will be changing the status of testcases to pass/fail/NA. While changing status, I will also add some files to it. Once I am done with changing status and attaching files for all tests, I will click on save button. Then all these attachments should go to folders with their respective testcaseids. I do not want them to be going to some single folder and get mixed up. I hope you understood my requirement now.

If I add attachments to testcases with ID 10000, 10001 and click on save button. I am expecting to move files attached to 10000 testcaseID to go into a folder named   attachments/testcases/10000
and files attached to 10001 to go into folder    attachments/testcases/10001. For this reason only, I need identifier for all the files I am attaching to. and I want to control that identifier. 

Please let me know if it is possible to know the random number that is attached to file name while saving that file to temp folder.

The example you attached will be moving all the files to single target folder and I do not want that thing to happen. I want files to be moving to different folders.


Thanks,
Anil
0
Hristo Valyavicharski
Telerik team
answered on 09 Dec 2013, 03:16 PM
Hi Anil,

You don't need to know the Temporary File name. I would suggest that you handle the OnFileUploaded event and store every file into the appropriate folder: 
protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
{
    //Get reference of the RadAsyncUpload
    RadAsyncUpload upload = (RadAsyncUpload)sender;
 
    //Get the DataKeyField
    var id = (upload.Parent.Parent as GridDataItem).GetDataKeyValue("TestID");
 
    //Generate the Target folder according to the Test's ID
    string target = Server.MapPath("~/Tests/" + id.ToString() + "/");
 
    //Check if the generated target folder exists. If it doesn't create it.
    if(!Directory.Exists(target))
    {
        Directory.CreateDirectory(target);
    }
 
    //Get the full file name
    string fullFileName = target + e.File.FileName;
    //Save the file
    e.File.SaveAs(fullFileName);
}

Sample is attached. 

Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Sean
Top achievements
Rank 1
answered on 05 Dec 2018, 07:33 PM

Hello,

I have similar question. In my case i want to give a temporary path (that i get from server) and permanent location(that i get from server as well). Basically, i have a grid with column of upload buttons which determines the temporary location and permanent location depending on row. I cannot seem to set temporaryfolder in "OnLoad" i can do TargetFolder in OnFileUploaded Event. I was wondering if there is a way to set TemporaryFolder during page load?

Moreover, is it possible to initiate FileUpload to Target folder from server side? Because i have pair of files. I want to select A to temporary location, B to temp location but save them to target location when i click upload RadButton. I encountered some problem with that such as file name is available via FileUploadedEventArgs and not via control like with asp:FileUpload. I want to prevent move to target on postback and only occur when i click the RadButton. 

Thank you,

Sean

Tags
General Discussions
Asked by
Anil
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Anil
Top achievements
Rank 1
Sean
Top achievements
Rank 1
Share this question
or