I'm currently stuck implementing image upload using CakePHP 1.3.
I am using the dropzonejs library to handle upload and post request for the server, the documentation for this library states the following:
Server side implementation
Dropzone does not provide the server side implementation of handling the files, but the way files are uploaded is identical to simple file upload forms like this:
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
</form>
I found some image upload code which looks like it would work, however I don't know how I can retrieve the post request using CakePHP 1.3.
Information about my setup
The image upload is located on the view: banners\\admin_index.ctp
The website URL for this location is: site.com/admin/banners/
I have a controller called banners_controller.ctp
which has the following functions:
admin_index()
-- Which renders the view add()
-- This uses $this->data
to save the files using uploadFile()
uploadFile()
-- This uploads the file onto the server Currently the add()
and uploadFile()
functions are not being used. I need to figure out how to handle the post request and direct it to these functions.
A full version of my code can be located here
In my view, I am creating the forms which dropzone.js links to like so:
<form action="add" class="dropzone" id="adropzone"></form>
When the form action is set to add
, it gives the response 'Server responded with 0 code.', when I look in the Chrome network tab, there is a request to 'admin/banners/add' and says (failed) net::ERR_BLOCKED_BY_CLIENT
. When I visit this page manually, I get a redirect loop: ERR_TOO_MANY_REDIRECTS
.
I am not very familiar with CakePHP 1.3 at all, however I am required to add this to the site, any help or links to external resources would be much appreciated.
Thanks.
您可以尝试https://blueimp.github.io/jQuery-File-Upload/与CakePHP文件上传插件
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.