Download jQuery Cakephp File

I am trying to download a blueimp file jimpi boot file that works with Cakephp.

Everything is fine, except that I am having problems trying to delete something that has been downloaded. I get an error below in the console when I click on delete in a specific file.

DELETE http://example.com.au/app/webroot/?file=logo%20%285%29.gif 404 (Not Found) jquery.min.js:4XHR finished loading: "http://example.com.au/app/webroot/?file=logo%20%285%29.gif". 

Is there a reason why this is happening?

+4
source share
1 answer

First of all, put all the necessary js and css files in the webroot directory.

Put them where you need, for example, the location of the js file inside webroot / js / jquery_file_upload / and css inside webroot / css / jquery_file_upload.

Now create the UploadHandler provider directory . Inside this directory, copy the UploadHandler.php paste.

Now you are almost done.

follow these steps.

  • In the example copy field, a copy of the copy of the file that you downloaded from here . do not forget to specify the correct path to each js and css files and in the form make sure that the name for the file input type is the files [] .
  • now one controller action has been created in which the real magic happens. copy paste the following code and specify the path as your requirement.
 <?php class ServicePicturesController extends AppController { var $name = 'ServicePictures'; function upload() { $this->layout = "ajax"; App::import('Vendor','UploadHandler',array<'file' => 'UploadHandler/UploadHandler.php')); $options = array ( 'script_url' => SITE_URL.'service_pictures/upload/', 'upload_dir' => APP.WEBROOT_DIR.DS.'img'.DS.'offer_picture'.DS, 'upload_url' => SITE_URL.'img/offer_picture/', 'max_number_of_files' => 3, 'thumbnail' => array ( 'max_width' => 150, 'max_height' => 150 ) ); $upload_handler = new UploadHandler($options, $initialize = false); switch ($_SERVER['REQUEST_METHOD']) { case 'HEAD': case 'GET': $upload_handler->get(); break; case 'POST': $upload_handler->post(); break; case 'DELETE': $upload_handler->delete(); break; default: header('HTTP/1.0 405 Method Not Allowed'); } exit; } ?> 

I did it successfully by spending 2 hours and testing it.

You can also integrate the database into it.

Feel free to ask more.

Hope this helps you and other fellow programmers.

Download the sample code from the link that I mentioned in the first step, follow these steps.

Put the js and css file as you wish, but put it in webroot for cakephp conventions.

Greetings.

+5
source

Source: https://habr.com/ru/post/1410974/


All Articles