Git Product home page Git Product logo

ajaxupload's Introduction

Hi, I’m Thomas Jakobi 👋

I am a german web-developer & designer based in Münsterland, Germany. I am the developer and/or maintainer of around 35 open source extras for MODX. I am the owner of Treehill Studio, an agency developing premium extras for MODX.

Open Source

I love open source and I commit some of my spare time in open source projects. Most of these projects are extensions to MODX, a content management system to build fast, secure websites.

If you like my work, you can sponsor me on GitHub Sponsors. You can also buy me a coffee (or two) on Ko-fi. I also offer paid coding of custom MODX extras.

Thomas's GitHub stats

Current work

My last open source extra for MODX was TwoFactorX, a MODX extra that adds a two-factor authentication to the MODX manager. Behind the curtain I am working on Cursus, a premium booking system for MODX on base of Agenda.

ajaxupload's People

Contributors

bugakov avatar dependabot[bot] avatar gvozdb avatar halftrainedharry avatar hugopeek avatar jako avatar nafem avatar vasia123 avatar weblate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ajaxupload's Issues

Js Error, loading the tutorial

Hi Jako,

I got an error in the console while trying to run your add-on: Uncaught TypeError: Object [object Object] has no method 'ajaxUpload'

I'm trying to insert this AjaxUpload into an existing Formit form. I added the snippet call, hooks- and prehook parameters as in the readme. I can confirm both js and html is loaded in the page:

<div id="file-uploader-image">
    <div class="file-uploader-items">

    </div>
    <div class="file-uploader-buttons">
        <noscript>
            <input type="file" name="image" />
        </noscript>
    </div>
</div>

...

<script type="text/javascript" src="/assets/components/ajaxupload/js/fileuploader.js"></script>
<script type="text/javascript" src="/assets/components/ajaxupload/js/ajaxupload.js"></script>
<script type="text/javascript">
    /* <![CDATA[ */
    $(document).ready(function() {
        $('#file-uploader-image').ajaxUpload({
            uploadAction: '/assets/components/ajaxupload/connector.php',
            uid: 'image',
            dragText: 'Drop files here to upload.',
            uploadButtonText: 'Upload',
            cancelButtonText: 'Cancel',
            failUploadText: 'Failed',
            deleteText: 'Delete',
            clearText: 'Delete all',
            hideShowDropArea: true,
            thumbX: '75px',
            thumbY: '75px',
            allowedExtensions: ['jpg','jpeg','png','gif'],
            sizeLimit: 8388608,
            maxFiles: 3,
            messages: {
                typeError: "Unfortunately the file(s) you selected weren't the type we were expecting. Only {extensions} files are allowed.",
                sizeError: "{file} is too large, maximum file size is {sizeLimit}.",
                minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
                emptyError: "{file} is empty, please select files again without it.",
                onLeave: "The files are being uploaded, if you leave now the upload will be cancelled."
            }
        });
    });
    /* ]]> */
</script>
</body>

What am I doing wrong?
Edit:
Running Revo 2.2.8-pl

Unique ID question

I'm not clear on how this works. Maybe I'm expecting it to work in the wrong way.

I have an order being placed with a PO number, I'd like to either amend the file name or create a unique folder for the image. Is this possible?

ajaxuploadAllowOverwrite enabled causing php timeout error

When a file with the same name exists in the upload folder AjaxUpload appends a _1 to the uploaded file when ajaxuploadAllowOverwrite is set to false. For example:

Upload download.jpg

  • download.jpg

Upload download.jpg again

  • download_1.jpg

When download.jpg is uploaded a third time this results in an error and the php script times out.

Nu buttons rendering in modal window

I have a bootstrap modal into which I load a resource with a formit form containing the ajaxupload snippet. However none of the buttons render in the form. When I use a plain resource not loaded in a modal the buttons render fine.

My snippet call is :
[[!AjaxUpload? &uid=image &allowedExtensions=jpg,jpeg,png,gif &thumbX=75 &thumbY=75 &maxFiles=1 ]]

After upgrading to 1.6.2, files fail to upload

Uploading files was working in 1.6.1. After upgrading to 1.6.2, files fail to upload and the following error appears in the modx error log

Error:
(ERROR @ /home4/blahblahpath/public_html/core/src/Revolution/modX.php : 1784) Unable to load processor for action "web/web/upload", it does not exist as an autoloadable class that extends \MODX\Revolution\Processors\Processor, and also not as a file in "/home4/blahblahpath/public_html/core/components/ajaxupload/processors/web/web/upload.class.php"

Size Limit issue

[[!AjaxUpload?
    &uid=`image`
    &allowedExtensions=`jpg, jpeg,png,gif,pdf,doc,docx`
    &maxFilesizeMb=`10`
    &maxFiles=`3`
    &thumbX=`50`
    &thumbY=`50`
    &sizeLimit=`10485760`
]]

The file uploader is not allowing me to upload files above 2 MB and getting the error logged "File is too large." I replace the script with essential file input, and it works fine. Still trying to figure out where to update the size limit.

array_key_exists() warning

Hello,

I'm using the following call;
[[!AjaxUpload?
&uid=image
&allowedExtensions=jpg,jpeg,png,gif
&thumbX=75
&thumbY=75
&maxFiles=5
&maxFilesizeMb=1
]]

I'm using Modx version 2.5.0 & php version 5.6.20. I saw the last comment from nick2687, but my jquery was already included at the bottom.
Since the latest upgrade of ajaxUpload,, the modx error log shows alot of the following errors;

[2016-08-07 11:13:33](ERROR @ /paas/c1879/www/core/components/ajaxupload/model/ajaxupload/ajaxupload.class.php : 108) PHP warning: array_key_exists() expects parameter 2 to be array, null given.

Original image gets deleted when the form is sent a second time

Hi Thomas,

I think its the desired behaviour but maybe there's an option to include a parameter to deactivate it. I ran into the problem as I am using ajaxupload for a raffle where users can send in their photos. In order to keep the server usage a bit lower I only allow one image each time the form is sent. But the user should be able to send the form multiple times and each time with a different image.

The only problem is, that the previous upload, whos path is written to the sessiondata, gets deleted in line 88 of AjaxUpload2Formit by „$ajaxUpload->deleteExisting();“. I guess the logic here was that a user who sends the form a second time is expected not to be happy with his first submit?

As that's not the case for my goal a short setting for the snippetcall would be nice. Just something like „deletePreviousSessionUpload“ or so.

Kind regards,
Fabian

Feature request: Custom validator to check if the field is not empty.

Custom validator to check if the field is not empty.
This almost works: Afbeeldingen_fileid:required` .
If the other to be validated fields are correct on first submission, then it works like a charm.
But after the form is submitted and an other to be validated field was left empty, then if you re-submit after correction, then it doesn't work anymore and will not validate the ajaxupload field.

MaxFiles not working en attachment not always correct

For some reason MaxFiles is not working. I can still upload more items then the number specified in MaxFiles.

Also when using Formit for attachment when I upload f.e. 3 items I only get 2 or 1 attachment in the mail. But sometimes it's correct. Strange behaviour.

Modx last version 2.5.7. Browser I use for testing: Firefox last version. Windows 10.

Upload not working for anonymous users in multiple contexts installations

Actually I am not sure if this is a bug, or if I am missing some configurations here.

I have a MODX installation with multiple contexts. Uploading is not working for anonymous users. (controller simply returns nothing, empty response) Once I authenticated in manager uploading is working. I tried to debug this issue using the controller.php file and imho the problem is in line 28:

$modx->user->getUserToken($modx->context->get('key'));

This is returning empty when used with multiple contexts whereas in single context installations this is returning a token. As I said before, I am not sure if this is a bug or a misconfiguration of my contexts, but I was able to reproduce this in two different installations both using multiple contexts.

MODX advanced installation 2.7.3
PHP 7.4

Error after installing AjaxUpload - array_key_exists

I've just installed this on a site and when attempting use the very basic snippet example you provide on the documentation site:

[[!AjaxUpload?
&uid=`image`
&allowedExtensions=`jpg,jpeg,png,gif`
&thumbX=`75`
&thumbY=`75`
]]

I receive the following error in the Modx error logs.

[2016-08-07 10:56:31] (ERROR @ /paas/c2064/www/core/components/ajaxupload/model/ajaxupload/ajaxupload.class.php : 108) PHP warning: array_key_exists() expects parameter 2 to be array, null given
[2016-08-07 10:56:31] (ERROR @ /paas/c2064/www/core/components/ajaxupload/model/ajaxupload/ajaxupload.class.php : 108) PHP warning: array_key_exists() expects parameter 2 to be array, null given

I'm using Modx version 2.5.1 & php version 5.6.20

Have you seen this before?

Default lexicon entry is not set with formit hook AjaxUploadRequired

I am currently testing the AjaxUploadRequired hook with formit. Per documentation I'd expect the default lexicon entry to render as the error message when no file is uploaded.

The form is not being submitted, but the error message is not being rendered.

I have to manually specify &ajaxuploadRequiredMessage to display an error message. Maybe there's some glitch.

Thanks in advance!

Setting language for text output of buttons

Where can you set what language the snippet AjaxUpload should use if you are NOT using the cultureKey and contexts for different languages?

In my situation I have a lang variable that holds either a 'en' or a 'de' as a value.

AjaxUpload Version 1.5.3
MODX 2.2.16

Call to undefined function tmpfile()

I'm running AjaxUpload in a FormitForm and am getting a fatal PHP error from fileuploader.class.php. The error doesn't make sense. It's failing to find the PHP tmefile() function. Here's the redacted error output:

PHP Fatal error:  Uncaught Error: Call to undefined function tmpfile() in /---/public_html/core/components/ajaxupload/model/fileuploader/fileuploader.class.php:38
Stack trace:
#0 /---/public_html/core/components/ajaxupload/model/fileuploader/fileuploader.class.php(195): qqUploadedFileXhr->save()
#1 /---/public_html/core/components/ajaxupload/processors/web/upload.class.php(100): qqFileUploader->handleUpload()
#2 /---/public_html/core/components/ajaxupload/processors/web/upload.class.php(38): AjaxUploadUploadProcessor->createUploads()
#3 /---/public_html/core/model/modx/modprocessor.class.php(185): AjaxUploadUploadProcessor->process()
#4 /---/public_html/core/model/modx/modx.class.php(1770): modProcessor->run()
#5 ...', referer: https://creationsabbath.net/your-creation-sabbath-story

Any idea what might be causing this? Any advice would be welcome.

MODX 2.8.4
AjaxUpload 1.6.5
Formit 4.2.7
PHP 8.2

FormIt Hook with FormIt2db

I am struggling with the following. I have a form that submits a custom resource via FormIt2db that contains an ajaxupload prehook to populate the form that runs fine on the form side. But after I Once I submit I need:

  1. the AjaxUpload2Formit hook to process the uploaded file into the correct location
  2. get the path/filename of the uploaded file and submit it as a field in the custom db record so it can be retrieved later as a part of the db record. My FormIt call looks like this:

[[!FormIt?
    &prehooks=`Formit2AjaxUpload,db2FormIt`
    &hooks=`AjaxUpload2Formit,Formit2db`
    &ajaxuploadFieldname=`document_url`
    &ajaxuploadTarget=`files/records/`
    &ajaxuploadUid=`record`
    &paramname=`resource_id`
    &fieldname=`id`
    &where=`{"id":[[+recordID]]}`    
    &prefix=`ws20_`
    &packagename=`ws20`
    &classname=`CostRecords`
    &tablename=`cost_records`
    &submitVar=`recordsubmit`
    &validate=`contract_id:required,waste_type_id:required,waste_category_id:required,record_type:required,document_url:required,amount:required,createdon:required,createdby:required,status_id:required`
    &successMessage=`Successfully added Record. Refresh your browser to view new data.`    
    &validationErrorBulkFormatJson=`1`
    &validationErrorMessage=`{"success":false,"errors":[[+errors]]}`
    &hookErrorJsonOutputPlaceholder=`hook_error_json_response`
    &errTpl=`[[+error]]`
]]

I see an email attachments hook and tried to get some ideas from that but no luck.
Has anyone tackled this or have any suggestions?

get an error with Formit 4.2.1-pl (MODX 2.7.1-pl | AjaxUpload 1.5.5-pl2)

Hi Jako, I get following in modx error log:

(ERROR @ /www/htdocs/web111/modx/core/components/ajaxupload/model/ajaxupload/ajaxupload.class.php : 139) PHP warning: include_once(/www/htdocs/web111/modx/core/components/formit/model/fileuploader/fileuploader.class.php): failed to open stream: Datei oder Verzeichnis nicht gefunden
(ERROR @ /www/htdocs/web111/modx/core/components/ajaxupload/model/ajaxupload/ajaxupload.class.php : 139) PHP warning: include_once(): Failed opening '/www/htdocs/web111/modx/core/components/formit/model/fileuploader/fileuploader.class.php' for inclusion (include_path='.:/usr/share/php:..')

I switched back to Formit 4.1.1-pl and get no error. Maybe you can fix it?

Generic error when uploading an image

On our local environment, everything works as expected, but on the production server we are getting a generic error message written to the browser:

Screenshot 2021-07-23 at 09 38 26

When comparing the network activity, on the production server no thumbnail is being generated. Write permissions are granted on all related folders - the cache folder inside of the components/ajaxupload folder, plus the folder used in the snippet configuration.

No errors are being logged in the modx error log.

Both the local environment and production environments are running php 7.3.

Any idea where we can look further?

Multiple AjaxUpload calls on same page no longer working with 1.6.0

After upgrading to 1.6.0 having multiple AjaxUpload calls on the same page is no longer working.

I compared to the output of 1.6.0 to the output of 1.5.8: the problem is caused by 1.6.0 only rendering JS code for one call while 1.5.8 was rendering a js block for every button with a different &uid.

This is the JS output for having two AjaxUpload calls on the same page:

1.5.8
1.5.8

1.6.0
1.6.0

These are the calls I am using:

[[!AjaxUpload?
    &uid=`cv`
    &allowedExtensions=`jpg,jpeg,png,gif,pdf`
    &thumbX=`75`
    &thumbY=`75`
    &maxFiles=`1`
]]

[[!AjaxUpload?
    &uid=`cl`
    &allowedExtensions=`jpg,jpeg,png,gif,pdf`
    &thumbX=`75`
    &thumbY=`75`
    &maxFiles=`1`
]]

File names with comma are not attached to email

This is because the CSV format breaks up the filename.

I'm already trying to come up with a workaround, but do you have any suggestions on how to approach it? Sanitize the filename? Or use a different separator?

Unable to upload video file formats

I am currently using AjaxUpload in conjunction with a Formit form. Below is the Formit snippet call:

[[!FormIt?
    &preHooks=`Formit2AjaxUpload`
    &hooks=`spam,AjaxUpload2Formit`
    &ajaxuploadFieldname=`campaign_video`
    &emailTpl=`form-campaign-request-email-tpl`
    &ajaxuploadTarget=`path-to-file`
    &ajaxuploadUid=`campaign_video`
    &ajaxuploadClearQueue=`1`
    &emailSubject=`Email Subject`
    &emailTo=`emailaddress`
    &successMessage=`Success Message`
    &submitVar=`campaign-submit`
]]

Below is the AjaxUpload call within the form:

[[!AjaxUpload?
        &uid=`campaign_video`
        &allowedExtensions=`mp4,mov,avi`
        &thumbX=`75`
        &thumbY=`75`
        &maxFilesizeMb=`50`
        &maxFiles=`1`
]]

Two other forms on my site that contain video upload fields are also no longer working, however they were working several months ago.

Email Attachment

I know this is vague but what reasons could prevent an image from not attaching to an email. I don't get any errors and don't know where to look. This is my formit setup:

&preHooks=`Formit2AjaxUpload`
&hooks=`recaptchav2,AjaxUpload2Formit,AjaxUploadAttachments,email,FormItAutoResponder,redirect`
&ajaxuploadFieldname=`image`
&ajaxuploadTarget=`../images/`
&ajaxuploadUid=`image`
&ajaxuploadAllowOverwrite=`true`
...

Not working on ajax-loaded page

I load the resource via JQ .get, the formit works well on such page, but ajax upload first showed nothing.
I tried to include style, script and inline script manually (in the fenom {ignore} tags) on that page, ajax upload appeared and "reacts", but ignores at least maxFiles setting and I'm not sure is working correctly.
E.g. &maxFiles=10 and .ajaxUpload({ maxFiles: 10 }) do nothing, still 3 files limit.

Limited uploads

I'm using this in an e-commerce site. Every order has an image upload. It won't add any more products. This only happens on products with the upload. This is my snippet:

[[!AjaxUpload?
&uid=`image`
&allowedExtensions=`jpg,jpeg,png,gif,mp3,avi,amr`
&thumbX=`75`
&thumbY=`75`
&maxFiles=`999`
&maxFilesizeMb=`50`
]]

Some customization

Nice extra but I haven't found the way to customize js part of it. I changed some js to load image path to hidden input to save it as TV through Tickets.

Modx 2.7.0 compatibility?

AjaxUpload stopped working in modx 2.7.0, with this error log:
[2018-12-12 11:29:36] (ERROR in modProcessor::run @ core/model/modx/modprocessor.class.php : 177) Flat file processor support is deprecated since version 2.7.0.

Uploaded Filenames are not Random

According to the docs, uploaded files automatically get random filenames:

Uploaded files and generated thumbnails gets random filenames to avoid hotlinking uploaded not published files.

Source: https://jako.github.io/AjaxUpload/

As far as I can see filenames are NOT changed.

If this is not the default behavious, how can I force it?

Regards,

pepebe

Quick Update: Apart from the missing random filename, everything is working fine. Files are uploaded to the expected place, and attachments are added to the outgloing mail. There are also no error messages or other problems.

I had a quick look at the snippets included and I could't find any code where a random filename would be generated.

Add option to sanitize file names

In addition to issue #69, maybe it would be nice to have an option to remove all spaces and special characters from the file names?

We sometimes observe that exotic filenames are not being attached, also with regular FormIt file upload fields.

Empty file named "assets" attached

When a form is sent without attaching a file, the email nevertheless shows an attachment file named "assets" with 0 Bytes in size. Some recipients might consider that as a harmful file. Is it possible to remove that?

ajaxupload.cache_expires not working as expected

Hi Thomas,

just discovered a minor bug regarding the cache_expires setting. On line 88 of ajaxupload.class.php the option is requested but its only requesting it from the snippet call, not from the systemssettings.

'cacheExpires' => intval($this->getOption('cacheExpires', $config, 4)),

For example in formit2ajaxupload.snippet.php it is requested from the system settings:

$scriptProperties['cacheExpires'] = $modx->getOption('ajaxuploadCacheExpires', $scriptProperties, $modx->getOption('ajaxupload.cache_expires', null, '4'));

I don't know what ajaxuploadCacheExpires is for as ajaxupload.cache_expires seems to be the right one, but maybe some backwards compatibility. You will know it :-) But it somehow confused me as there is cacheExpires, ajaxuploadCacheExpires, ajaxupload.cache_expires for basically the same thing.

But long story short: If you change the setting inside the system settings and also when calling the snippet by &cacheExpires=8760 for example everything works correct but I wouldn't expect, that I have to change it in two places to make it work correct.

Kind regards,
Fabian

Problem with AjaxUpload

Hallo, Jako! I have problem with AjaxUpload. When I try to upload files, parameter fileid generated not correctly, it dublicated. If I upload 10 files, AjaxUpload upload 5 or 6 files. Sorry, for my english. Attach screenshot:
default

After updating MODX to 2.8.6-pl, AjaxUpload no longer seems to work

After updating MODX to 2.8.6-pl, AjaxUpload no longer seems to work. The page with the formit call is loaded, the AjaxUplaod form is displayed. You can now add a file for uploading and shortly afterwards the counter (kb) appears and then the display changes to error. No messages in the error log, nor any info when enabling the debug mode.

ajayupaoderror

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.