⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

set_image_upload function??



Cèsar Martí
  • profile picture
  • Member

Posted 14 March 2012 - 17:05 PM

Hello everybody.

I realise, in the [b]grocery config[/b], there're a few paremeters of "image upload": image_upload_allow_file_types, image_upload_max_file_size, image_upload_default_dir, image_upload_default_url, image_upload_max_width, image_upload_max_height, image_upload_thumb_width, image_upload_thumb_height and image_upload_create_thumbnail.

However, I don't see in the library any function like "[b]set_image_upload[/b]".

I'd like, in the same form, to upload a "[b]normal file[/b]" and a "[b]image file[/b]", and to check (to validate), from the config file, for example, the "file_upload_allow_file_types" (for the "normal file") and the "image_upload_allow_file_types" (for the "image file"). How could I do that?

Thanks for the attention.

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 14 March 2012 - 18:44 PM

You have downloaded the trunk version that's why. This functionality is not ready. First I want to release the version 1.2 and after this I will plan to work on it.

Cèsar Martí
  • profile picture
  • Member

Posted 15 March 2012 - 08:37 AM

You're right, I'm working with the trunk version. I'll love this new functionality. So, at the moment, what would be the way to have more than one upload field in a form with different [b]file_upload_allow_file_types[/b] and [b]file_upload_max_file_size[/b]? Thank you.

Cèsar Martí
  • profile picture
  • Member

Posted 16 March 2012 - 12:40 PM

Please Johnny, could you help me with this?

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 20 March 2012 - 21:57 PM

I have an example of how to use the callback_after_upload with the image_moo library at: http://www.grocerycrud.com/documentation/options_functions/callback_after_upload . It works fine as for version 1.2

Cèsar Martí
  • profile picture
  • Member

Posted 27 March 2012 - 13:28 PM

This could be useful, for sure, but I've still the same problem. Wht I'd like to do it's to updload two files (ore more) in the same form, but with diferent "allow_file_types" at least. Any suggestion? Thanks.

Cèsar Martí
  • profile picture
  • Member

Posted 27 March 2012 - 16:46 PM

Ok, this what I'm trying, to develop a temporary "[b]set_image_upload[/b]" function, just copying and renaming functions, parameters, etc. wich are used in "[b]set_field_upload[/b]". But reading from config "[b]grocery_crud_image_upload_allow_file_types[/b]" and "[b]grocery_crud_image_upload_max_file_size[/b]" instead of "[b]grocery_crud_file_upload_allow_file_types[/b]" and "[b]grocery_crud_file_upload_max_file_size[/b]".

In the attached file you can find my changes between something like this

// *** MEU *****
(new code)
// **************

Just search "MEU".

The problem, it's not working. The validation of "allow_file" and "max_file" is ok, but I get the error "An error has occurred on uploading." when it's trying to upload. Could you have a look in the file and find what I did wrong? Just realise, the folder of "css" and "js" files it's not the same than the original library.

Thanks a lot.


PS: It could be awesome, once it be working, instead of appear a link to the image uploaded, to see a thumbnail like your example.

EDIT: I found the problem, now it's working. I attach the file again, the good one.