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

RadUpload does not upload file

14 Answers 901 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
David House
Top achievements
Rank 2
David House asked on 01 Jun 2010, 06:46 AM
We have placed a RadUpload control in a DotNetNuke module and selected the file. We also have an asp:button on the control set to Submit. When we press the button, the RadUpload.UploadedFiles.Count is always ZERO and the file never gets uploaded. The page is being refreshed by the submit button during the postback.

Here is the GUI code:

 

<asp:Panel ID="pnlFileUpload" runat="server">

 

Allowed File Extensions are: .jpg, .gif, .bmp, .png

 

<telerik:RadUpload id="RadUpload1" Runat="server" AllowedFileExtensions="jpg, gif, bmp, png" TargetFolder="~\Portals\0\ClientLogos" MaxFileInputsCount="1" >

 

 

</telerik:RadUpload>

 

 

<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />

 

 

</asp:Panel>

 



the btnUpload button is set to UseSubmitBehavior=True. What are we missing?  DotNetNuke version 5.04.02 community.

14 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 03 Jun 2010, 02:19 PM
Hello David House,

Please make sure that RadUpload is not inside UpdatePanel/RadAjaxPanel or ajafixied using RadAjaxManager. RadUpload cannot upload files using AJAX calls. This is a limitation of the XmlHttpRequest component, used in all AJAX frameworks for asynchronous calls to the application. In order to upload a file your application must perform a full page postback. More information on the topic can be found here. You can also take a look at this troubleshoot article, describing a case when the uploaded files collection is empty.

In addition, information on how RadUpload can be used inside DNN can be found here.

Best wishes,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chuck
Top achievements
Rank 1
answered on 12 Mar 2012, 08:52 PM
I have the exact issue; however, mine is not inside of DNN.
Here's my code. It's not uploading.

<telerik:RadUpload ID="RadUpload1" Runat="server" Height="131px"
        MaxFileSize="204800" TargetFolder="~/TempFiles/" TargetPhysicalFolder="~/Upload/">
    </telerik:RadUpload>
    <asp:Button ID="btnUpload" runat="server" Text="Upload" />
0
Chuck
Top achievements
Rank 1
answered on 13 Mar 2012, 03:37 AM
Okay, I just followed this Getting Started tutorial and it's still not uploading. Below is my code:
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
<telerik:RadUpload ID="rduFile" Runat="server" MaxFileSize="204800"
    TargetFolder="~/Media" AllowedFileExtensions=".mp3"
        ControlObjectsVisibility="RemoveButtons"
        MaxFileInputsCount="1" Skin="Forest" Height="25px">
</telerik:RadUpload>
<telerik:RadProgressManager ID="RadProgressManager1" Runat="server" />
    <telerik:RadProgressArea ID="RadProgressArea1" Runat="server"
        DisplayCancelButton="True"
        ProgressIndicators="TotalProgressBar, TotalProgress, TotalProgressPercent, RequestSize, FilesCountBar, FilesCount, SelectedFilesCount, CurrentFileName, TimeElapsed, TimeEstimated, TransferSpeed"
        Skin="Forest">
    </telerik:RadProgressArea>
<asp:Button ID="btUpload" runat="server" Text="Upload" onclick="btUpload_Click" />

And here's the button click method.
protected void btUpload_Click(object sender, EventArgs e)
   {
       if (rduFile.UploadedFiles.Count > 0)
       {
           System.Threading.Thread.Sleep(3000);
       }
   }

Any other suggestion?
0
Dimitar Terziev
Telerik team
answered on 15 Mar 2012, 11:14 AM
Hello Chuck,

If the UploadedFiles collection is empty than the uploaded file is not valid. The problem in your case is the size of the MaxFileSize property. Please note that this property defines the maximum allow file size in bytes which means that currently you could upload files which are less than 200 killobytes. You should increase this property especially of you want to upload mp3 files. Here you could find a useful only converter.

Kind regards,
Dimitar Terziev
the Telerik team
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 their blog feed now.
0
Chuck
Top achievements
Rank 1
answered on 16 Mar 2012, 03:08 PM
Okay, that works. I thought the MaxFileSize property is set KiloByte and not Byte. Anyway, the progress bar never showed up. Any suggestion why?
0
Chuck
Top achievements
Rank 1
answered on 16 Mar 2012, 09:26 PM
One other thing, how do I grab the file name of the RadUpload control and store it in my own database?
0
Dimitar Terziev
Telerik team
answered on 20 Mar 2012, 10:07 AM
Hello,

Here is a sample code showing how to get the name of the uploaded file:
protected void Button_Click(object sender, EventArgs e)
{
    foreach (UploadedFile file in RadUpload1.UploadedFiles)
    {
        file.SaveAs(Server.MapPath("~/Uploads/" + file.GetName()));
    }
}

You could also use the GetExtension() method which will give you only the extension of the uploaded file.

Greetings,
Dimitar Terziev
the Telerik team
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 their blog feed now.
0
Chuck
Top achievements
Rank 1
answered on 21 Mar 2012, 04:03 PM
Thanks for the response; however, I still not quite get what you're code is trying to do. I'm not trying to save because the RadUpload is already doing that. I'm simply getting the file name. Here is what I've done with the standard FileUpload control in Visual Studio 2010:
e.Values["fileName"] = FileUpload1.FileName;

So, the question is. How do I do the same thing with RadUpload? I do not see the "FileName" or "File.GetName" being available.
0
Chuck
Top achievements
Rank 1
answered on 21 Mar 2012, 04:40 PM
One other thing is, how do I test if the RadUpload1 uploaded successfully? For example:
if(RadUpload1.Upload.Success)
{
// add the file name into the database here
}
else{ e.cancle = true}


0
Richard
Top achievements
Rank 1
answered on 23 Mar 2012, 08:27 PM
Chuck:

You can refer to the RadUpload Context documentation page which states: "You can access all uploaded files within the current request using the RadUploadContext object. The RadUploadContext object has a single property: UploadedFiles. UploadedFiles is a collection of all files that have been uploaded within the current request."

UploadedFiles is a collection of all valid uploaded files.

This is how you can access the name for each uploaded file for that request, using the "GetName()" property:
foreach (UploadedFile f in RadUpload1.UploadedFiles)
{  
    // Get the file name for each file that is uploaded
    string fileName = f.GetName();
    // add logic to store this name in your database
}

Hope this helps!
0
Chuck
Top achievements
Rank 1
answered on 26 Mar 2012, 07:52 PM
Thanks! I'll give that a try. However, what about my second question? How do I test if the RadUpload1 uploaded successfully?
0
Dimitar Terziev
Telerik team
answered on 29 Mar 2012, 08:41 AM
Hi,

In case the UploadedFiles collection of the RadUpload is not empty after you have selected a file for upload, than the file is being uploaded successfully.

All the best,
Dimitar Terziev
the Telerik team
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 their blog feed now.
0
Waseem
Top achievements
Rank 1
answered on 15 Nov 2012, 09:58 PM
I am very worry about this issue?
Path is 100% correct and has full permission. Its work locally as well as on server. but one of our client get this error. i have no idea.
Can you help me in this? Please see latest images.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Testing\Test.pdf'.

[DirectoryNotFoundException: Could not find a part of the path 'D:\Testing\Test.pdf'.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +216
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) +2481
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +229
0
Waseem
Top achievements
Rank 1
answered on 24 Nov 2012, 02:33 PM
Hi Telerik team and members , please don't use againfile.GetName() or file.FileName.

I got the solution of this issue, its only arise in IE on few particular computer. After uploading it again and again and checking on client computer. i figure out this. So nobody suffer with again file.GetName() or file.FileName.

This problem is arise due to this: When we getting UploadedFile  name [  file.FileName.ToString() ]
So need to use this
file.GetNameWithoutExtension() + file.GetExtension();
instead of file.FileName.ToString();

string targetFolder = System.Web.HttpContext.Current.Server.MapPath(@"~/TestUpload");
string file1 = file.GetNameWithoutExtension() + file.GetExtension();
string targetFileName = System.IO.Path.Combine(targetFolder, file1);

Thanks,
Muhammad Waseem

Tags
Upload (Obsolete)
Asked by
David House
Top achievements
Rank 2
Answers by
Genady Sergeev
Telerik team
Chuck
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Richard
Top achievements
Rank 1
Waseem
Top achievements
Rank 1
Share this question
or