Jump to content

Multiple Image Upload and Storing a Specific Amount of Values Controlled By User


norwegianfellah

Recommended Posts

Hello again, guys!

I have a couple of questions that I hope anyone can answer.

 

I am making a form that is storing the information in a database, and in this form I also want images to be uploaded.

I want to make a function that allows the user to upload as many images as they would like to have in their ad on my website, and I also need something that can handle the upload process, and see how many images the user is trying to upload. Any easy solutions for this? :)

 

I also have another question:

As you can see on the example image underneath this text, I have a form with multiple inputs where the user is suppose to choose how many inputs they want to fill in themself.

How should I store this information in the database, and how can I make a script that detects how many of the forms the user actually filled?

 

I hope you guys understood what I was trying to say, and I thank you all anyways.

Underneath you can see an image of my forms.

 

Example image:

21m7sk2.jpg

 

Cheers,

Marius

uploading multiple files is easy on the field name for the files add [] for an array for multiple

 

this is a function i use in my phpbb download section..

while(list($key,$value) = each($_FILES[upload_image][name]))
		{
			if(!empty($value))
			{   // this will check if any blank field is entered
				$filename = $value;    // filename stores the value

				$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
				$fanme = $dlid . "_" . $filename;
				//$target_path = "../dlfiles/screens/" . $fanme;
				$this->setMessage($target_path);
				$sql = "INSERT INTO `".DL_SS_TABLE."` (`did`, `url`, `uploaded`) VALUES ('" . $dlid . "', '" . $target_url . "','1')";
				$this->setMessage($sql);

				//*
				if (move_uploaded_file ( $_FILES ['upload_image'] ['tmp_name'], $target_path )) 
				{
					$this->setMessage("The image " . $_FILES ['upload_image'] ['name'] . " has been uploaded");

					$this->makethumb ( $_FILES ['upload_image'] ['name'], $target_path, $id2 );

					$sql = "INSERT INTO `".DL_SS_TABLE."` (`did`, `url`, `uploaded`) VALUES ('" . $dlid . "', '" . $target_path . "','1')";
					$result = $db->sql_query ( $sql );
				} 
				else 
				{
					$this->setMessage("Your uploaded was unseccessful");
					exit ();
				}
				//*/

			}
		}

upload_image is ofcourse the name of my file field on my form i hope this helps..

Thanks, that kinda helped out a bit.. Still don't understand how to create the array, and make the user able to choose how many images they want to upload themselves.. :confused:

Also I wonder about the multiple inputs, where only the inputs with value is going to be put in the database :confused:

 

set a base amount of fields on the page then have a dropdown with numbers from the base amount to the max you want and then that refreshes the page and makes more fields... if you look it up online you should be able to find how to do it ... and my function there ignores empty fields

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.