I'm currently developing a form upload feature specifically designed for use in Zend Framework forms. My goal is to create a seamless integration that can be easily implemented into any project without the need for manual configuration.
This unique uploader utilizes AJAX technology to handle file uploads and returns data in JSON format, such as:
[
{
"name":"image.png",
"size":42410,
"type":"image\/png",
"url":"http:\/\/example.com\/image.png",
"thumbnail_url":"http:\/\/example.com\/thumbnail\/image.png",
}
]
As the uploader functions as a form element itself, I am faced with the challenge of incorporating this data into the form submission process so that it can be easily retrieved from the $_POST array. Initially, I attempted to add hidden input fields dynamically through JavaScript with the name uploader-data[], but this limited me to passing only one variable at a time.
Therefore, my main query revolves around finding a solution to pass the entire array/object to the $_POST/form. Despite utilizing AJAX for the uploader, I prefer traditional form submission methods over relying on AJAX to submit the form. My objective is to have a standard form submission containing all the data extracted from the JSON object/array. Although the files are already uploaded, I may wish to store the JSON data in my database or utilize it elsewhere.
Is it feasible to achieve this functionality?
Your insights and assistance would be greatly appreciated.