Language: PHP / MySQL
I'll lose my mind, I really need to ask now ... I have a form for uploading multiple files:
<input type="file" name="fileupload[]" multiple>
With some Javascript, for every change made to this input, it adds a list of file names + a formatted string (grabbed from the file name) inside another input, so when replacing, we have a layout as shown below (assuming we just added some Images):
Almost similar to: http://jsfiddle.net/pxfunc/WWNnV/4/
// HTML representation of such a layout will be ... (suppose we added 3 images)
<input type="file" name="fileupload[]" multiple>
- image-name-1.jpg
<input type="text" value="Image Name 1" name="keyword[]">
- justsome_file.png
<input type="text" value="Justsome File" name="keyword[]">
- some_Img-031.gif
<input type="text" value="Some Img 031" name="keyword[]">
<input type="submit" value="Upload">
I have this because, in addition to downloading files, I would also like to add them to my database with a default header based on its file name (and with the ability to set / change this name for each image when it is downloaded). There is no problem with my form.
PROBLEM: My dilemma lies inside the PHP page on which the form data / action is presented.
I can only be:
- Download the right images, but get the same name for everyone
- Insert the correct headers, but get the same image for everyone
Here is my PHP action page: (currently loading the correct images, but has the same title for everyone)
<?php
(I use the Colin Verot Download Class to handle image downloads and a guide to their FAQ for processing. MULTIPLE uploads images to this page in the section: How about multiple downloads? )
This would work perfectly if I just uploaded the images, however I added the functionality of adding each image to my database. and that's where he gets confused.
I am sure that the key places the SQL query inside the right foreach or maybe does another one, but I tried this and it gives me only 1 good result for loading an image or title, never others.
I need to upload an image to a site and then save its data (including the path to the images) in my database.
Please take a look at my code and enlighten me how to solve this problem? The key to the fragment would really be beautiful, as I am already very confused, having tried everything I could think of. Thank you very much!