We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45950
    • 40 Posts
    I've gotten everything to work with one exception...
    it uploads and writes to the db with the path for the image assets/images/user/2/
    however the images are still in the cache folder... is this an encoded path or are they supposed to actually go to the folder on submit?
    • The file is copied from there to the target folder and stays in cache just to avoid retreive the original and save it to cache everytime the page is reloaded. The cache is cleaned automatic after 4 hours if another file is uploaded by AjaxUpload.
        • 36804
        • 19 Posts
        Hi,

        I am using a conditional loader (modernizr->yepnope) and ajaxupload.js executing prior to jquery being instantiated in my queue.

        Aside from rewriting the plugin, are there any options for a delayed instantiation of ajaxupload?
        • &addJscript=`0` and reference the ajaxupload.js in the conditional loader.
            • 36804
            • 19 Posts
            Duh, thanks. I was probing around in the component and forgot to rtfm.

            fyi: I also had to wrap the script.tpl in a function and explicitly call that after loading ajaxupload.js
            [ed. note: hyponym last edited this post 10 years, 1 month ago.]
              • 36804
              • 19 Posts
              I'd like to use AjaxUpload->clearCache(0) to remove previously uploaded files in a form where the user can edit fields without uploading new images. Currently, cached images are submitted unless the user manually deletes them.

              Is this a good idea and whereabouts should it get called in the formit process?

              In the Formit2AjaxUpload prehook?


              Quote from: Jako at Oct 20, 2013, 03:39 PM
              The upload connector itself is not secured on user permission (this could be provided by changing the connector). Random filenames (for uploads and thumbs) during upload avoid hotlinking of uploaded files that are not moved to target after form submission.

              The only problem that could occur is posssible floading the server with uploaded files. Uploaded files stay in cache for 4 hours per default. Automatic purging will executed after each upload. The cache could be cleaned manually by calling AjaxUpload::clearCache(xxx) with other values in xxx.
              • If you don't want to submit any images by the form, you just don't have to call the AjaxUpload2Formit hook and call AjaxUpload->clearCache(3600) + AjaxUpload->clearValue() after validation in an own hook. clearCache(0) would delete cached files from other users too, so don't set it that short.
                  • 36804
                  • 19 Posts
                  Thanks Jako but perhaps I didn't clarify my issue enough:

                  If i edit two separate resources and upload an image in the first, when I go to edit the second, the image uploaded in the first resource is still in the cache and is displayed in the second resource.

                  The Problem: Unless I manually remove the image using the minus icon, it gets uploaded into my second resource.

                  So how would I clear any cached items in the upload form every time a user edits a resource?


                  In the interim I've hacked it with the following JS which I'm calling after the page is rendered:

                  function removeCachedImages(){
                  		var imgholder = $('#file-uploader-photos').find('.delete-button');
                  
                  		if (imgholder){
                  			$(imgholder).each( function(){
                  				$(this).trigger('click');
                  			});
                  		}
                  	}



                  Quote from: Jako at Apr 02, 2014, 12:05 AM
                  If you don't want to submit any images by the form, you just don't have to call the AjaxUpload2Formit hook and call AjaxUpload->clearCache(3600) + AjaxUpload->clearValue() after validation in an own hook. clearCache(0) would delete cached files from other users too, so don't set it that short.
                  [ed. note: hyponym last edited this post 10 years ago.]
                  • You could generate the AjaxUpload uid on page base i.e. &uid=`image_[[*id]]`. With that the upload queues are separated in the session.
                      • 42046
                      • 436 Posts
                      Hi,

                      I'm trying to allow the uploading of pdf and docx files, but despite including these in &allowedExtensions and even trying the snippet default properties, it's still stating "it should be one of jpg,jpeg,png,gif".

                      Any suggestions?

                      Edit: I've added the extensions to line 57 of ajaxupload.class.php and it's working now. Seems like they are hardcoded and &allowedExtensions is not being passed on. [ed. note: absent42 last edited this post 9 years, 9 months ago.]