Cakephp: working multiple files uploads – script ready to download
These days I’ve been trying to make Bogdan Lungu’s cakephp image upload script to work with Stickman’s multiple file element javascript. After two days I finally managed to make it work, so for everyone to save working time I placed the script here. It comes with file structure and readme file so everything should be working fine. For the original script visit Bogdan Lungu’s  cakephp dedicated section of website. If something goes wrong feel free to comment here.
Download multiple-file-upload-with-cakephp.zip
Daca iti place cum scriu aboneaza-te la RSS feed!. Daca nu iti place, aboneaza-te totusi! Acuma da-mi pace! Pa!





Hey Mishu!
I tried this script.
The javascript thign is cool and works fine.
But when I submit the form, I get errors which indicate that the directory doesn’t exist.
I have created the directories upload/big and upload/small within webroot. But still I get the same errors.
Hi man,
It’s been a long time since I used this script. It would help if you could paste the error here.
Hi mishu!
“Warning: imagecreatefromjpeg(upload\big\DSC00160–1223901408.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in C:\wamp\www\app\controllers\components\image.php on line 7″
Thats the error I got(and then an array of other GD-libraryerrors caused by this error).
I also changed line 17 and 18 to
$uploaddir1 = “upload” . DS . “big” ;
$uploaddir2 = “upload” . DS . “small” ;
And changed line 48 to:
$newfile = $uploaddir1 . DS. $temp;
And then also changed line 57 to:
$newfile2 = $uploaddir2 . DS. $temp;
I am using cakephp 1.1 on Windows XP and WAMP
If you can get online
I’m on the freenode #cakephp irc as SingAlong
Also mishu,
I created the upload directories within webroot.
My upload dirs are app/webroot/upload/big and app/webroot/upload/small
Those details aren’t mentioned in the readme.txt file in your zip download. I found it when I compared your code with Bogdan Lungu’s script(he had used foto/big and foto/small within webroot dir).
Also thanks for this script(and hope you can make it work). Its a very useful one.
As I look at it it seems to me that you have only a path problem. I am no longer using cake so I can’t help you with this issue. Please try again from the beginning and it should work out. Follow the instructions on the txt file and let me know if you encounter further problems.
Its not a path problem mishu. I found the problem. It was the image size problem. I as trying to upload an image that was 3.5mb.
Tried smaller images and it worked. Seems liek my php.ini file is limiting me.
Thanks for the quick reply!
But where do I limit the number of the total files uploadable?
Which var should I change in the multifile.js?
Ah! found out that too. In the multiselector function.
I’ll soon post an update with an updated script.
I am adding more image types to the script.
Thanks mishu! The script works like a dream!
You’re welcome, glad I could help ’cause it took me several days to put this head to head and I thought it would be good sharing it with other people so I could spare them some fits
I’ll update the files on my server with the issues you raised so there won’t be further problems for other people
Is there any way of adding an input text box to every file upload box?
Like I would like to allow user to describe every file in a line. So I would like to have an input text box. Can you hint as to what changes I need to make to multifile.js get it this way with an input description box?
You dont have to update much mishu. Just add some more instructions in the readme.txt file and remove the controller code in the readme.txt file. It should make things simpler.
The most important instruction is where to create the upload/small and upload/big directories. Thats not been mentioned.
Can u help me out with that input box addition. I tried editing multifile.js
I changed:
if( element.tagName == ‘INPUT’ && element.type == ‘file’ )
to:
if( element.tagName == ‘INPUT’ && (element.type == ‘file’ || element.type == ‘text’))
and added “var new_element2″ and assigned a new input box.
But the input box doesnt seem to disappear when I click on add file
And I get a whole of input boxes. Funny me.
Sorry man, gotta go now. You’re on your own on this but if I get some ideas I’ll sure let you know by email
sure! I add support for more image types and mail you back. (u have my email address in your comments)