CodeIgniter Forums
How To Best Handle Image Uploads In A CMS - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How To Best Handle Image Uploads In A CMS (/showthread.php?tid=36985)



How To Best Handle Image Uploads In A CMS - El Forum - 12-22-2010

[eluser]mdvaldosta[/eluser]
Standard file/image uploading isn't a problem, what IS a problem (that I've spent 2 days on, so far) is how to handle uploading an image on a form (like a posting screen in a CMS) without submitting the whole form. I don't want to use some pre-made complicated script, I need to do it in a way I can understand and build upon.

My preferred setup/logic is like so:

1. Form has a posting box, with a WYSIWYG editor. The image uploading will not be integrated.
2. I need to upload the image and display info about it on the page, but not submit the form because I don't want to do validation yet.

Essentially, this is the same way GMAIL handles uploads in emails. I believe they use an iframe to do this. Thoughts?

PS - I'm currently trying to get uploadify working (not sure why it doesn't work, as it works fine outside of CI). I'd really rather be able to do this with simple php/html/javascript in a controller/view though.


How To Best Handle Image Uploads In A CMS - El Forum - 12-22-2010

[eluser]Krzemo[/eluser]
If you dont want to submit on image upload - this will work only with JS. Best to do make it work with no JS fallback.
Focusing only on JS solution (im gonna use jQuery here):
You can use http://valums.com/ajax-upload/ and as a response from server send html
Code:
<input type="hidden" name="images[]" value="uploadedimagefilename.jpg" />
<img src="uploadedimagefilename.jpg" />
and then just do jQuery JS
Code:
$("form").append(server_response);
this way you will have your form updated with hidden fields having info on uploaded images and when submitting it POST will have all info to save them.

This is very simplified but should give you a hint.

Regs
K


How To Best Handle Image Uploads In A CMS - El Forum - 12-22-2010

[eluser]mi6crazyheart[/eluser]
I think this will ( http://www.viewsboard.com/index.php/dboard/viewthread/28/182 ) give u some help.