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

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.