Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to utilize dojo uploading files via AJAX?
    primarykey
    data
    text
    <p>I would like to use the <code>dojox.form.Uploader</code> widget to handle file uploads to the server via AJAX.</p> <p>I included the needed definitions:</p> <pre><code>dojo.require('dojox.form.Uploader'); dojo.require('dojox.form.uploader.plugins.HTML5'); </code></pre> <p>I declaratively created an instance of <code>Uploader</code>:</p> <pre><code>&lt;div name="docUpload" multiple="false" type="file" dojoType="dojox.form.Uploader" id="docUpload" label="Upload Doc" uploadOnSelect="true" url="/ajax.php?foo=bar"&gt; &lt;script type="dojo/connect" event="onComplete"&gt; /* ... */ &lt;/script&gt; &lt;/div&gt; </code></pre> <p>The <code>uploadOnSelect</code> seems to work somehow, because <code>/ajax.php</code> gets a request, which is visible in the messagelog. Furthermore the js console receives a <code>COMPLETED</code> message after a few seconds.</p> <p>Strangely the <code>$_FILES</code> array in <code>/ajax.php</code> remains empty. I'm logging the following:</p> <pre><code>syslog(LOG_WARNING, json_encode($_REQUEST)); syslog(LOG_WARNING, json_encode($_FILES)); </code></pre> <p>Output:</p> <p><em><strong>Dec 6 13:27:09 reline httpd2-prefork: {"foo":"bar"} Dec 6 13:27:09 reline httpd2-prefork: []</em></strong></p> <p>Is my understanding of how to PHP-process the uploaded file wrong? Or is it a technical problem?</p> <p><strong>EDIT</strong></p> <p>I tried wrapping the widget inside a multipart-form but id didn't have any effect:</p> <pre><code>&lt;form method="post" action="/ajax.php?foo=bar" id="docUploadForm" enctype="multipart/form-data"&gt; &lt;div name="docUpload" multiple="false" type="file" dojoType="dojox.form.Uploader" id="docUpload" label="Upload Doc" uploadOnSelect="true"&gt; &lt;script type="dojo/connect" event="onComplete"&gt; /* ... */ &lt;/script&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Log output is the same:</p> <p><em><strong>Dec 6 16:04:20 reline httpd2-prefork: {"foo":"bar"} Dec 6 16:04:20 reline httpd2-prefork: []</em></strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload