Jump to content

Broken upload form with images and fields


illuz1on

Recommended Posts

Hello

 

Can anyone PLEASE tell me what is wrong with this code below? It uploads the images, but not to the made directory called $name, and it inserts all SQL fine, just the upload to the specific directory isnt working?

 

Please really desperate

 

Thanks Chris

 

<?

require_once("db.php");

while(list($key,$value) = each($_FILES[images][name]))
	{
		if(!empty($value))
		{
			$name2 = $_POST['$name'];
			$filename = $name2;

			mkdir("../women/$name2", 0777);

				$add = "../women/$name2/$filename";
                       //echo $_FILES[images][type][$key];
		     // echo "<br>";
				copy($_FILES[images][tmp_name][$key], $add);
				chmod("$add",0777);


		}
	}

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("capetown_a", $con);
$sql="INSERT INTO women (name, height, weight, chest, eyes, hair) VALUES ('$_POST[name]','$_POST[height]','$_POST[weight]', '$_POST[chest]', '$_POST[eyes]', '$_POST[hair]')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
$name2 = $_GET['$name'];
echo "Model Added - Check to see if she is valid! - $name - $name2"; 


?>

Link to comment
Share on other sites

Don't assume the upload works, and check and move the files using these functions:

 

http://us3.php.net/manual/en/function.is-uploaded-file.php

 

http://us3.php.net/manual/en/function.move-uploaded-file.php

 

 

You should not have directories created off the fly if you can help it. The $name2 needs to be validated so it doesn't contain characters that can't be in directory names. Same for $filename. Check the directory doesn't exist already before trying to create it.

 

You should post the html upload form so members can help you better too.

 

 

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.