When I add a "TargetFolder" the temp file creates itself in RadUploadTemp, but immediately disappears.
It only works if I remove the target folder. i.e the temporary file remains in RadUploadTemp and I can manipulate the image.
Why is it failing if I set a TargetFolder?
<telerik:RadAsyncUpload ID="AsyncUpload1" runat="server" OnClientFilesUploaded="OnClientFilesUploaded"
OnFileUploaded="AsyncUpload1_FileUploaded" MaxFileSize="2097152" AllowedFileExtensions="jpg,png,gif,bmp"
AutoAddFileInputs="false" Localization-Select="Select" TargetFolder="~/images">
6 Answers, 1 is accepted
In RadAsyncUpload the Uploaded files are stored in a temporary location until a postback occurs. The temporary location is cleaned-up automatically. When posted, files are saved to the designated temp folder (App_Data/RadUploadTemp by default) with unique names. Once a postback occurs the RadAsyncUpload fires the OnFileUploaded event for each file. After the events fire, all files are automatically saved to the TargetFolder. Finally, all processed temporary files are deleted. If there is no TargetFolder is set , the uploaded file remains in the TemporaryFolder and it will automatically delete after 4 hours.
If I set the Target Directory property, and select a file, it is copying it immediately to the Target Directory and therefore immediately deletes the temporary file, so I don't have the opportunity to manipulate the temporary file in the editor before saving it.
Have I understood that correctly?
I had assumed the example wouldn't copied the file to the target folder until I pressed "save" on the image editor.
So how do I prevent the file being immediately copied to the Target Folder in the context of this example?
To be able to manipulate the files as desired you can use the OnFileUploaded event and implement the desired logic in the event handler. Note, however, that you should not set the TargetFolder property in the markup of the control. Attached to this post you can find a very simplified project. Give it a try and let me know how it goes.
I can now upload, manipulate and save the image, and manipulate an existing image and save it.
Another question. When clicking "save" on the image editor, is it possible to stop the dialogue box appearing and force It to just save to the server and use the existing filename, and pop-up a save-file success or failure message?
You can prevent the dialog box to appear and respectively add the needed logic when clicking on the save button. Here you can check how this could be achieved using the RadEditor control.