SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Customization of some parameters Options
donnapep
#1 Posted : Friday, June 13, 2008 12:52:33 PM
Rank: Newbie

Groups: Registered

Joined: 6/13/2008
Posts: 1

Hello,

Is there a way to specify the location to which to save the file to programmatically? Our app. saves to a different folder location depending on the client who is logged in.

Also, is there a way to set whether or not to overwrite existing files on a per request basis? I would like for the user to be able to select a checkbox to decide whether or not they want to overwrite  the file, if it exists.

Both of these are currently set in web.config, so just wondering if there's another way?

Thx.

ChrisHynes
#2 Posted : Saturday, June 14, 2008 4:36:20 PM
Rank: Administration


Groups:

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

You can use a custom FileNameGenerator to accomplish both of these. Take a look at the FileNameGenerator sample to see the framework. Basically, the logic you define in your filename generator will be called for each file that is uploaded. That way you can put files in different folders based on logged in user.

For the user preference on overwriting, it is similar. Set the existingAction mode to overwrite. Then, in your filename generator, check to see if the file exists and overwrite is off. If so, supply a different filename (perhaps appending a [1] to the filename as browsers do) to supply a new filename.

One thing to keep in mind as you do this is that you will not be able to read other non-file form elements when your file name generator is called. This is because browsers send up forms with files and other elements intermixed, so there is no guarantee of element order. All elements are read sequentially. So the checkbox will have to be done in a user preference dialog or a different wizard step. Or perhaps an ajax call. If you don't want to opt for an extra step, another option would be to use the Guid file naming method, and then perform the logic and move the files in the UploadManager's UploadComplete event. At that point, all form elements will be available, so you can read the checkbox value.

Let me know if you have additional questions regarding this.

salalimo
#3 Posted : Wednesday, June 25, 2008 8:37:04 PM
Rank: Newbie

Groups: Registered

Joined: 12/3/2007
Posts: 2
If we have: existingAction="Rename", and I use the following code to retrieve the filename:

for (int i = 0; i
{
it.MoveNext();
Krystalware.SlickUpload.UploadedFile fr = (Krystalware.SlickUpload.UploadedFile)it.Current;
string f = fr.ClientName;
}


The problem is that when a file with the same name exists it saves the file on disk appending to it '[1]' or [2].... (which is desired) but the filename that is fetched does not have the appended information with it. Is there an easier way than fetching all the files and checking whether the filename is there, and them checking whether the filename[1] is there... and then adding the [ n ] to it?

Thanks.
ChrisHynes
#4 Posted : Thursday, June 26, 2008 3:00:40 PM
Rank: Administration


Groups:

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Sure... Index into the LocationInfo dictionary to get the server file name:

string path = file.LocationInfo[FileUploadStreamProvider.FileNameKey];

For answers to this and other questions, check out the SlickUpload FAQ.

salalimo
#5 Posted : Friday, June 27, 2008 5:52:35 PM
Rank: Newbie

Groups: Registered

Joined: 12/3/2007
Posts: 2
When doing the rename option, when there are no files in a directory, and we upload file: x.txt, the uploaded file shows up as: x[1].txt.

Is there a way to not append anything to a file when its the first file of that name in that directory.

Thanks in advance.
ChrisHynes
#6 Posted : Friday, June 27, 2008 11:58:56 PM
Rank: Administration


Groups:

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ
I'll take a look at this and get back to you by Monday.
Users browsing this topic
Guest
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.