i am stuck on trying to upload and display image files...i'm using a very simple, basic script...here's the code;
if(isset($_POST["submit"])){
$name = $_POST["name"];
$photo = $_FILES["photo"]["name"];
define("UPLOAD_PATH","images/");
if(!empty($name) && !empty($photo)){
$dbc = mysqli_connect('localhost','MY USERNAME','PASS','DB') #the details here are correct.
or die("Could not establish connection");
$target = UPLOAD_PATH.$photo;
if(move_uploaded_file($_FILES["photo"]["temp_name"],$target))
echo "success";
$query = "INSERT INTO folder VALUES ('$name','$photo')";
mysqli_query($dbc,$query);
echo "Thanks for adding your photo: ".$photo." $name";
echo "<br /><img src='".UPLOAD_PATH.$photo."' alt='photo'";
mysqli_close($dbc);
$name = "";
$photo = "";
}else{
echo "please add a photo and your name";
}
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" value="1024000" name="MAX_FILE_SIZE" />
<label for="name">Name</label>
<input type="text" name="name" id="name" /><br />
<label for="upload">Upload</label>
<input type="file" name="photo" id="photo" /><br />
<input type="submit" name="submit" value="Enter" />
I do not know a lot about move_uploaded_file so i hope you can help me in any way you can.
After submission no image is being displayed and but the path to the image is indeed what I want...i believe the error is coming straight from move_uploaded_file...it's not being moved...folder is empty!!

New Topic/Question
Reply



MultiQuote




|