Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
maw1048  
#1 Posted : Thursday, October 9, 2008 7:42:14 AM(UTC)
maw1048

Rank: Newbie

Groups: Member
Joined: 10/9/2008(UTC)
Posts: 5

I'm trying to evaluate the ImageUploader as an upload solution for our application. In evaluating it, I have a question.

How does the image uploader handle uploads for files that already exist in the destination directory?

How are the files that already exist in the destination directory during the upload communicated back to the client?

Our business rules dictate that if a file already exists in the destination directory, we want to be able to ask the user if they wish to replace the file or not to replace it.

Does anyone have any ideas on how to accomplish this with this control?

My original thoughts would be to save the list of files that existed in the destination directory in Session during the processing of upload.aspx, and redirect them to another page to ask the user if they wish to overwrite these files.

Thanks in advance for any help.

Fedor  
#2 Posted : Thursday, October 9, 2008 10:30:32 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,556

Thanks: 5 times
Was thanked: 62 time(s) in 61 post(s)
Hello,

Quote:
I'm trying to evaluate the ImageUploader as an upload solution for our application. In evaluating it, I have a question.


First off all let me clarify that Image Uploader is just client-side control/applet which uploads data to the specified URL. You can implement any logic on server side you want. All server code samples shipped with Image Uploader are just samples.

Quote:
How does the image uploader handle uploads for files that already exist in the destination directory?


As i have said you can implement any logic, either rename files to prevent conflicts or overwrite existing files.

Quote:
How are the files that already exist in the destination directory during the upload communicated back to the client?


You can send any response from server, which you can handle later on client side using ImageUploader.Progress Event.

For example if file exists you can write in ASP.NET :

Code:
Response.Write("FILEEXIST");


Then handle it on client side:

Code:
<script type="text/javascript" src="iuembed.js"></script>
<script type="text/javascript">
function ImageUploaderID_Progress(Status, Progress, ValueMax, Value, StatusText) {
	if (Status == "COMPLETE" && Status =="FILEEXIST") {
		//Do some code
	}
}
var iu = new ImageUploaderWriter("ImageUploaderID", 610, 500);
//...params...
//...other event listeners...
iu.addEventListener("Progress", "ImageUploaderID_Progress");
//...other event listeners...
iu.writeHtml();
</script>


You can ask user whether to overwrite file. After it you should someway send callback to server either using Image Uploader or AJAX approach.

If you need detailed sample please let me know your server platform.

Quote:
My original thoughts would be to save the list of files that existed in the destination directory in Session during the processing of upload.aspx, and redirect them to another page to ask the user if they wish to overwrite these files.


Yes, it is also good idea.

Edited by user Thursday, October 9, 2008 10:35:56 AM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
maw1048  
#3 Posted : Monday, October 13, 2008 12:12:04 AM(UTC)
maw1048

Rank: Newbie

Groups: Member
Joined: 10/9/2008(UTC)
Posts: 5

Thanks for the info!
ebaker355  
#4 Posted : Saturday, July 14, 2012 6:44:11 PM(UTC)
ebaker355

Rank: Newbie

Groups: Member
Joined: 7/14/2012(UTC)
Posts: 3

Fedor, can you please elaborate how you would implement server side logic to overwrite existing files? It seems the default behavior is to add a "_2" to the filename of an uploaded file, if it already exists on the server. How can I overwrite existing files instead?

Thanks!
Dmitry.Obukhov  
#5 Posted : Monday, July 16, 2012 12:20:11 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Dale,

As far as I remember, you develop with ASP.NET. Our standard ASP.NET samples for Image Uploader include special script which allows to rename file (adding suffix) if it already exists. You can find this method in the App_Code/Utils.cs file - GetSafeFileName() method. This method is used when an uploaded file is saved, e.g.:
Code:
string sourceName = Utils.GetSafeFileName(gallery.UploadedFilesAbsolutePath, uploadedFile.SourceName);

To just overwrite an existed file, you should use this code:
Code:
string sourceName = uploadedFile.SourceName;

If you have any additional questions please feel free to let me know.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.