Not able to run upload.php using YUI Uploader

576 views Asked by At

I'm trying to get YUI uploader work on my computer / localhost, by using this example . The javascript the page use, can be view here.

The upload button has the following handler:

YUE.on('upload', 'click',  this.upload, null, this);

(...)

upload : function(e) {
    YUD.get('browse').style.display = 'none';

    this.uploader.disable();
    this.uploader.uploadAll('wp-content/themes/storelocator/include/upload.php', 'GET');
},

The PHP file looks like this:

<?php
  echo "TEST";
?>

When I click the upload button, the page is reloaded, but nothing is echoed. The upload button is simple html button <button id="upload">Upload</button>.

Is there are reason why "test" is not echoed?

2

There are 2 answers

1
dfilkovi On

Well I never used a YUI framework but every upload script I know makes an hidden iframe somewhere on a page cause it is not possible to upload a file using ajax.

I believe that script works, just use firebug to find that hidden iframe and in it you will find your TEST string echoed.

0
Pav On

In uploadAll, you need to specify an absolute path. Specifying a relative path will not work. So instead of having it as : 'wp-content/themes/storelocator/include/upload.php' you need to make it 'http://www.yourdomain.com/wp-content/themes/storelocator/include/upload.php'. Hope this helps!