illuz1on Posted October 28, 2007 Share Posted October 28, 2007 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/75132-broken-upload-form-with-images-and-fields/ Share on other sites More sharing options...
toplay Posted October 28, 2007 Share Posted October 28, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/75132-broken-upload-form-with-images-and-fields/#findComment-379985 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.