Welcome Guest Search | Active Topics | Sign In | Register

Final File Location Options
Jon Fairchild
Posted: Tuesday, March 4, 2008 1:58:40 PM
Rank: Newbie
Groups: Member

Joined: 3/4/2008
Posts: 5
I am using the basic sample code, and can not get it to actually do the move to the finalfilelocation. I am setting the finalfilelocation thus:

Code: Visual Basic.NET
Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
   AjaxUploader1.FinalFileLocation = Server.MapPath("db/_filelibrary/" & Request.QueryString("id"))
 End Sub 'Page_Load


I have this as the code on the aspx page:
<eo:AJAXUploader runat="server" id="AJAXUploader1" Width="400px" TempFileLocation="~/eo_upload" MaxDataSize="40000"
ProgressDialogID="AJAXUploaderProgressDialog1" AutoPostBack="True">

Thanks,
Jon
Jon Fairchild
Posted: Tuesday, March 4, 2008 2:01:19 PM
Rank: Newbie
Groups: Member

Joined: 3/4/2008
Posts: 5
I should also mention, the following sub does not have any results...

Code: Visual Basic.NET
Private Sub AJAXUploader1_FileUploaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles AJAXUploader1.FileUploaded
            'Get all the posted files
            Dim files As EO.Web.AJAXPostedFile() = AJAXUploader1.PostedFiles

            'Delete all posted files

            Dim s As String = String.Empty
            Dim file As EO.Web.AJAXPostedFile
            For Each file In files
                s += System.IO.Path.GetFileName(file.TempFileName)
                s += "<br />."
            Next file
            
           lblFiles.Text = s

        End Sub 'AJAXUploader1_FileUploaded
eo_support
Posted: Tuesday, March 4, 2008 2:08:31 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

file.TempFileName won't have any result when you set FinalFileLocation (as stated in the help file: "This property returns null (Visual Basic Nothing) if FinalFileLocation is set, in which case you should use FinalFileName"), so you will need to change that to FinalFileName first. Once you change it to FinalFileName, you should see the file name.

Also make sure the directory specified by FileFileLocation exists and writable to your application (you can try to make it writable to "Everyone" as a test). You can also try to put a fixed path first (instead of setting it in Page_Load) and see if it works.

Thanks

Thanks
Jon Fairchild
Posted: Wednesday, March 5, 2008 7:31:28 AM
Rank: Newbie
Groups: Member

Joined: 3/4/2008
Posts: 5
Ok, I did the following:
1. Changed the sub to use the FinalFileName
Code: Visual Basic.NET
Private Sub AJAXUploader1_FileUploaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles AJAXUploader1.FileUploaded
            'Get all the posted files
            Dim files As EO.Web.AJAXPostedFile() = AJAXUploader1.PostedFiles

            'Delete all posted files

            Dim s As String = String.Empty
            Dim file As EO.Web.AJAXPostedFile
            For Each file In files
                s += System.IO.Path.GetFileName(file.FinalFileName)
                s += "<br />."
            Next file

            lblFiles.Text = s
        End Sub 'AJAXUploader1_FileUploaded


However, I still don't get any file names written out.


I also set the FinalFileUpload in the AJAXUploader Control instead of in the Page_Load:
<eo:AJAXUploader runat="server" id="AJAXUploader1" Width="400px" TempFileLocation="~/eo_upload" MaxDataSize="40000"
ProgressDialogID="AJAXUploaderProgressDialog1" AutoPostBack="True" FinalFileLocation="d:\client websites\test\db\_filelibrary\test">

The upload works fine, lists the file, but it doesn't delete the temp files, and it doesn't move it to the finalfilelocation. I've tested permissions, given Everyone "write" permissions, etc. Do I need to call a specific action from the File_Uploaded sub to make it do the move, and delete the temporary files?

Thanks!
eo_support
Posted: Wednesday, March 5, 2008 7:42:12 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Did you have the page posted back at all? In another word, have you checked whether FileUploaded is fired?

The uploader does not automatically post back the page (which is required to fire any server event) by default. With our uploader, uploading a file is like type a word in a textbox, while the file has already been transmitted to the TempFileLocation on the server, it is not officially submitted (thus copied to FinalFileLocation) until you submit the page --- for example, by another button in the page.

If this is the case, you can put another button in the page to submit the result, or set the uploader's AutoPostBack to true. AutoPostBack instructs the uploader to automatically post back when upload is done.

In any case, you can try to debug through AJAXUploader1_FileUploaded handler and figure out whether it is hit, if hit, why there is nothing out, whether its AJAXUploader1.PostedFiles is empty or anything else, it should be fairly easy to get to the bottom once you step through it.

Let us know how it goes.

Thanks
Jon Fairchild
Posted: Wednesday, March 5, 2008 8:01:04 AM
Rank: Newbie
Groups: Member

Joined: 3/4/2008
Posts: 5
I set the control to AutoPostback, and there was no change. I'm simply using one of the demos included with the code.

I have a page with one control in it
<uc1:Upload ID="UploadDemo" runat="server" EnableViewState="False"></uc1:Upload>This includes demo.ascx - in which I have
<eo:AJAXUploader runat="server" id="AJAXUploader1" Width="400px" TempFileLocation="~/eo_upload" MaxDataSize="40000"
ProgressDialogID="AJAXUploaderProgressDialog1" AutoPostBack="True" FinalFileLocation="~/db/_filelibrary/bob">


Theoretically, I don't even have to have anything in the code behind file based on this set up, is that correct? I did try to change the FinalFileLocation to ~/ reference, but no changes.

This code behind sub never gets called from what I can tell:
Private Sub AJAXUploader1_FileUploaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles AJAXUploader1.FileUploaded
Thanks,
Jon
eo_support
Posted: Wednesday, March 5, 2008 8:17:20 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Try remove EnableViewState="False" on your uc1:Upload user control. I don't think uploader works with view state disabled. It needs view state to save information about the uploaded files.

Thanks
Jon Fairchild
Posted: Wednesday, March 5, 2008 8:30:03 AM
Rank: Newbie
Groups: Member

Joined: 3/4/2008
Posts: 5
Looks like that was it - working beautifully now. Will definately make a purchase! I think the control over the layout is awesome.
eo_support
Posted: Wednesday, March 5, 2008 8:35:11 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Cool! Let us know if you have any more questions!


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.