Uploading images from a form via ajax with other types of fields
Hi everyone,
I am new to Ajax and fairly strong with PHP but have never worked with images before. I have a form that adds employee details to a MySQL database via Ajax and I need to upload a photograph, resize it to keep the presentation uniform, and then be able to enter its path (or filename) into a table field.
I have Googled this to death and can't seem to find a solution. My form uses jQuery's .ajax() to submit the form and I only need to attach one image. I have found several plug-ins and scripts out there for performing Ajax file uploads but most are for multiple files and do not seem to factor in the possibility of the form containing other data that still needs to be processed after the image is uploaded.
I figured out, for the most part, how to resize the image after it is uploaded using PHP but since the form is submitted via Ajax, I am unsure how to validate it and give the user feedback. So, essentially this is what I need to do -
Upload the image via Ajax, alert the user if it is too large or the wrong format, and append the filename to either an input box or hidden form field so that it can be added to the mySQL entry along with the rest of the data when the form is submitted.
Any help would be GREATLY appreciated.
Thanks
Ben