Jump to content

how are uploaded files stored ?


jd2007

Recommended Posts

Check this out it works for me.

 

<?php
include ('db_connect.php');

# Directory / Filenameto be upload
$newimage = "Copy_File/image.jpg";
if($_POST['Upload']) {

if(empty($_FILES['pic'])) {
print "Empty field";
}
if(!empty($_FILES['pic'])) {
$image = $_FILES['pic'];
move_uploaded_file($_FILES['pic']["tmp_name"], $newimage);
print "Picture is uploaded!";
$query = mysql_query("INSERT INTO message VALUES('','USER_NAME','MESSAGE','TIME','$newimage')") or die (mysql_error());
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body marginheight="200" marginwidth="300">
<form name="upload" action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
Upload Image: <input type="file" name="pic" size="15" />
<input type="submit" name="Upload" value="Upload" />
</form>
</body>
</html>

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.