Cakephp: working multiple files uploads – script ready to download

Scris de mishu 19 comentarii Friday, February 8th, 2008

in categoria: cod? eu??? asa se pare!

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

19 comentarii la “Cakephp: working multiple files uploads – script ready to download”

  1. Akash says:

    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.

  2. mishu says:

    Hi man,
    It’s been a long time since I used this script. It would help if you could paste the error here.

  3. Akash says:

    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

  4. Akash says:

    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.

  5. mishu says:

    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.

  6. Akash says:

    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?

  7. Akash says:

    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.

  8. Akash says:

    Thanks mishu! The script works like a dream!

  9. mishu says:

    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 :)

  10. mishu says:

    I’ll update the files on my server with the issues you raised so there won’t be further problems for other people

  11. Akash says:

    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?

  12. mishu says:

    :) ) , no. but I’ll think about it :)

  13. Akash says:

    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.

  14. Akash says:

    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. :)

  15. mishu says:

    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

  16. Akash says:

    sure! I add support for more image types and mail you back. (u have my email address in your comments) :)

  17. sadas says:

    =)) ;;) :cry: :) ) :p

  18. fazal says:

    Hi
    “i Hope you are fine ,happy for guide multiple file upload .
    thanks for this acts”;
    fazal

  19. mishu says:

    A long, long time ago :)

    You’re welcome, hope this helps

Comenteaza

escort ankara