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

Changing upload

5 Answers 62 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Samantha
Top achievements
Rank 1
Samantha asked on 03 Oct 2009, 07:05 PM
I have a RadUpload control inside an UpdatePanel with UpdateMode set to conditional, and the RadUpload has a TargetPhysicalFolder specified.  I specify an image to upload, and then in the FileExists event save the name of the file to a label control (so I can write the location to a DB).  This works fine.

If I browse back to the page, and try to upload another file to in a sense change the uploaded file, the FileExists event does not fire again so I can't write the filename to the label and update it in the database.

[code]

<

 

asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">

 

 

<ContentTemplate>

 

 

<telerik:RadUpload ID="RadUploadLogo" runat="server" EnableAjaxSkinRendering="False"

 

 

EnableEmbeddedBaseStylesheet="False" EnableEmbeddedSkins="False"

 

 

TargetPhysicalFolder="C:\Test"

 

 

EnableFileInputSkinning="False" CssClass="formfields" AllowedFileExtensions=".gif"

 

 

ControlObjectsVisibility="None" onfileexists="RadUploadLogo_FileExists">

 

 

</telerik:RadUpload></ContentTemplate></asp:UpdatePanel>

 

protected

 

void RadUploadLogo_FileExists(object sender, Telerik.Web.UI.Upload.UploadedFileEventArgs e)

 

{

lblUploadFileName.Text =

String.Format("C:\\Test\\{0}", e.UploadedFile.GetName());

 

}

[/code]

Is there a way to make the FileExists event fire again?

5 Answers, 1 is accepted

Sort by
0
Vesko
Top achievements
Rank 2
answered on 07 Oct 2009, 11:57 AM
Here is an extract from the docs:

The server-side FileExists event occurs when the following three conditions hold:

  • The TargetFolder or TargetPhysicalFolder property is set.
  • The OverwriteExistingFiles property is set to false.
  • The target folder already contains a file with the same name as the currently uploaded file.

Make sure that all of these conditions are met.


0
Samantha
Top achievements
Rank 1
answered on 08 Oct 2009, 07:50 PM
The problem exists with *new* files, with a different file name.
0
Vesko
Top achievements
Rank 2
answered on 09 Oct 2009, 01:57 PM
FileExists will fire only if the file with the same name already exists. All three conditions I pasted above should be met.
0
Accepted
Wim van der Linden
Top achievements
Rank 1
answered on 10 Oct 2009, 01:18 PM
Hi,

how about using the onValidatingFile?
this always triggers and triggers before the actual file upload.
From there you can see if the file is valid and even cancel it if needed.
So it seems to me you got everything you need there.

kind regards,
Wim
0
Samantha
Top achievements
Rank 1
answered on 12 Oct 2009, 05:30 PM
That was exactly what I needed, thank you!!
Tags
Upload (Obsolete)
Asked by
Samantha
Top achievements
Rank 1
Answers by
Vesko
Top achievements
Rank 2
Samantha
Top achievements
Rank 1
Wim van der Linden
Top achievements
Rank 1
Share this question
or