|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hello,
I'm trying to implement the AjaxUploader without the ability for the user to be able to upload multiple files i.e. I dont want to keep the list of files they have uploaded because only the last final one they upload is relevant.
My AJaxUploader markup looks like so:
<eo:AJAXUploader id="AJAXUploader" runat="server" Width="439px" TempFileLocation="~/lib/uploadTmp" MaxDataSize="<%$AppSettings:EO.maxFileSizeBytes %>" Height="168px" OnFileUploaded="AJAXUploader_FileUploaded" SavePostedFileList="false" Rows="1" ClientSideOnStart="uploadStart" ClientSideOnDone="uploadDone" ClientSideOnError="uploadError" AllowedExtension="<%$AppSettings:EO.allowedFileExts %>" > ........ </eo:AJAXUploader>
As you can see, I have set the SavePostedFileList equal to false, however whenever I loop through the postedfilelist or implement the postedfileplaceholder object it lists all the files the user has uploaded.
How can i get round this? It is driving me barmy as i have set the parameters the documentation suggests!
Thanks in advance Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
SavePostedFileList has no effect until your page is posted back (when FileUploaded event is fired). If you wish to control the number of files allowed before post back, you will need to set MaxFileCount. When MaxFileCount is reached, both browse and upload button are disabled so user won't be able to upload any more files. If user changed his/her mind and wants to upload another file, he/she can delete the previous item from the file list. That will re-enable the browse/upload button again. If you do not display the file list to the user, then you must post back the page to the server, then call ClearPostedFiles to clear the list.
Hope this helps.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hello,
Thanks for your response.
I have tried option 2 by adding AutoPostBack="true". The documentation appears to suggest that the OnFileUploaded event will be triggered when the page is posted back, however its not. Do i have to call my event handler i.e. AJAXUploader_FileUploaded from within my Page_Load code?
Regards, Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
No. You should never call the event handler directly. FileUploaded should be triggered once user uploads a file and then post back (either through AutoPostBack or through something else such as click a submit button). By defintion, FileUploaded event is fired when user uploads a file. However because it is a server event, so like any other server event, it is triggered only when the page posts back. If it does not fire at all, I would suggest you to try it from a blank page or load the sample page to see whether it fires. It is very important that you have the event firing correctly. This event not firing is like the Click event not firing for a Button control.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hi,
The event fires fine when a user manually clicks the submit button, but it does not fire when the autopostback parameter on the ajaxuploader is set to "true".
Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That is not normal. Please try to isolate the problem into a test page and we will be happy to take a look.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hi,
Again, thanks for your response.
I'll try and get an example together, but my page really isnt doing anything that most ASP.NET pages do...like include jQuery files! Every single thing ive attempted with this control have resulted in errors so far.
I even implemented your first solution displaying the postedfilelist to the user, the problem with this is as soon as the page is postedback, the list remains but the delete button doesnt!
Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We do need a test page that can duplicate the exact scenario in order to investigate further. Not only that we need it in order to see the problem, but also we need it to confirm whatever solution we come up will indeed work for you. Otherwise both of us would be shooting in the dark and most of the time it will just be a waste of time for all. So please try to duplicate the error and also identify the triggering part. If the test page also rely on external files (such as JQuery script) please try to create a test project that includes all the files and send it us in zip format (let us know if you need to do that so that we can give you the email address). In any case please make sure the test page/project only contains code that is needed to duplicate the problem.
Thanks
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hello,
Yes, please provide the email address so i can send you the files. I have not included the web.config file as it includes too much information, however the example will work if you plug-in a web.config file simply adding the essentialobjects parts.
Regards, Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We have received your test project. The test project runs fine when AutoPostBack is set to true. User would click "Browse" to browse a file, click "Upload" to start upload, then the progress bar starts to move. Once that is done the page is posted back and FileUploaded is fired. This is contrary to what you mentioned in your previous post ("but it does not fire when the autopostback parameter on the ajaxuploader is set to true").
As to your other questions:
1. You can completely elimiate the "upload" button by setting AutoUpload to true. That way the upload starts automatically as soon as user browses a file;
2. It is normal that you do not see the "Delete" button because you have already moved the file away. AJAXUploader can only delete a file when it is still in temp directory. Once it is moved away the file is considered as "accepted" and uploader will no longer touch it (it wouldn't know where you moved it to even if it wanted to);
Hope this helps.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hi,
Thanks for your response.
Ok, that all makes sense, however I think you misunderstand what im tring to achieve. Run my test project again, however remove the following line of code : <asp:Button ID="UploadButton" runat="server" Text="Upload" />
On line 74 of upload.aspx you will see there is a standard .NET submit button. I want the progress bar to trigger when the user clicks this button. So essentially the following will happen:
1) User selects file. 2) Add notes into the text box underneath the file field. 3) Clicks Submit (Progress Bar activates)
Is this possible?
Regards, Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Yes. You can do that. What you need to do is to 1. Replace the asp:Button with a something like this:
Code: HTML/ASPX
<input type="button" value="Upload" onclick="start_upload()" />
Code: JavaScript
function start_upload()
{
//Get the AJAXUploader object. You will need to relace
//"Uploader1" with the client ID of your uploader control
var uploader = eo_GetObject("Uploader1");
//Start upload. This will start moving progress bar
uploader.upload();
}
2. Set the uploader's AutoPostBack to true. This is necessary so that once the upload completes, the whole page is submitted; 3. Handle the uploader's FileUploaded event. This is the event you will be handling because you no longer have a server side asp:Button "UploadButton"; Hope this helps. Thanks
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hi,
Thanks for your response. However you say, "Handle the uploader's FileUploaded event"..Do i need to do anything other than was in the example i sent over? That was already referencing the FileUploaded event which was being called when the page was posted back - however with the HTML button this doesnt seem to happen.
Regards, Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
It should happen if you set the uploader's AutoPostBack to true. When it is set to true, the uploader triggers post back (thus triggers FileUpload event) when the progress bar reaches the end. When it is set to false the uploader will just sit there (waiting for you to submit the page) when the progress bar reaches the end.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hi,
Could you please modify the example i sent to you to get this working. I have amde the changes to the project and not only does the progressbar not move, but the page eventually the page displays an alert message:
EO.Web control 'AJAXUploader' error message. AJAX call to the server times out.
I do appreciate the support you are providing, however I am somewhat surprised at the number of problems that have been encountered trying to get a single file upload with progress bar working.
Regards, Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
As we have already stated in our previous reply, the sample code you sent to us works just fine. You claimed that FileUploaded event wasn't called. We verified and it is called. Obviously it doesn’t give us the error message you encountered either (otherwise we would have told you). So there is really nothing for us to do with that code.
We would recommend you run the sample project and get everything working first. For example, if you can not upload a file inside your application, can you upload a file with the sample project? That way if a problem does occur, you will be able to tell us when I do this and this with this sample it does not behave as it supposes to. We will then investigate that and let you know what we can find. Sometimes the issue has to do the product, sometimes the issue has to do with your code, sometimes the issue has to do with the environment (for example, your server settings). You will always need to isolate the problem first. We won’t investigate a problem unless you can clearly isolate and reproduce the problem. Starting from the sample can clearly tell you whether the problem is related to the component or related to your code/project.
While we do our best to help you use our product, we generally do not troubleshoot user code or code for our user. So usually we will say no if you ask us to modify your code to do what you wanted (We do always look into project that clients sent to us to reproduce a problem). We tell you how the product should behave and give you the sample code. If the sample code does not work, we will look into it; If your code does not work, try to isolate the problem and create a reproducing page/project and we will look into it. We also expect you to follow our instructions. Like previously we explicitly asked you to set AutoPostBack to true and you seem to still have missed it. Those are not product problems.
If you continue to have problem, please try to create a new test project to clearly demonstrate the issue and send to us again (make sure also include detailed step by step instructions on how to reproduce the problem).
Thanks
|
|
Rank: Member Groups: Member
Joined: 4/22/2010 Posts: 13
|
Hello,
Again, thanks for your response.
I appreciate you are not here to fix developers code - however you have no documentation regarding uploading a file from an independant button i.e. one that does nto exist within the AJAXUpload template layout - so when I asked you how this could be acheived you provided a code example - thank you very much. When i plugged your exact code into the test project which we both agree was working, it stopped working - therefore that really leaves me nowhere else to go with the component. It's probably fantastic if you want to upload multiple files, however i'd bet the majority of the people on this forum need to upload just the one!
Al
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
higgsy wrote:When i plugged your exact code into the test project which we both agree was working, it stopped working - therefore that really leaves me nowhere else to go with the component That's exactly why we need you to provide a new test project and be very specific about what issue you are having and steps you use to reproduce the problem. I understand in this case you have already sent us a test project and is just plugging in the code snippet that we provided, but maybe you plugged it in differently than we thought you would have. That's why we have to see your new code to find out what's wrong with it. I thought we have already cleared your question about uploading multiple files. Does that have anything to do with what we are talking about here or it’s just something else you are throwing into the mix? If it is, please try to keep it as a separate issue and we will work with you one by one. In the future if you still have any problem with the product, please always try to isolate the problem into a test project, then send it to us along with detailed step by step instructions to reproduce the problem. Can you do that? Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, We have received your new test code and the code looks fine to us. There are some minor issues (one being Response.Write has no effect inside a Callback, other being MapPath code didn't work) but none should affect how the uploader works. The does not appear the additional script we asked you to put in will cause the problem you described. In another word, your original code would not have worked either. Thus it appears that problem you are having either has to do with your project or your environment. The best way to confirm this is to put your test code in our sample project and then run it from there. If it works, then you know the problem is related to your project or your environment. From there you can further identify whether it has to do with your project or your server (for example, you can create a blank new application on your server and then try the test code in that project). You can also go over these items and see if it helps: http://doc.essentialobjects.com/library/1/ajaxuploader/troubleshoot.aspxI would suggest you start with the last section ("Try a regular file input element") first. AJAXUploader is built on top of the standard file upload mechanism. If that doesn't work for you, then nothing will work for you. If the problem is indeed has to do with your project, then it usually has to do with other httpModules in your web.config. In that case you can just try to trim down your project step by step and you should be able to identify what broke the uploader. If the problem has to do with your server or server application settings, then it can be a wide variety of issues. The best way for you to troubleshoot is to create a new test app and then compare. We can do those for you but not only there is an additional charge by hours for that, but also we need admin access to your server, so I am not sure whether it's worth it for you. Thanks
|
|