wolfandcrow
IS-IT--Management
i have been at this for 4 hours every thing i read on google searchers does not work what am trying to do is add an image as a blob to mysql and a file to my dir and add the path to mysql but no matter what i try i can only get 1 of them to work at any 1 time?
html form
<form method="post" enctype="multipart/form-data" action="add.php">
<input type="file" name="userfile[]">
<input type="file" name="userfile[]">
<input type="submit" name="Submit">
and then my add.php
$postdate=date("d/m/y h:i:s"); //create date time
$uploadDir = '/file/';
if ($_FILES)
{
$image_types = Array ("image/bmp",
"image/jpeg",
"image/pjpeg",
"image/gif",
"image/x-png");
if (is_uploaded_file ($_FILES['userfile']['tmp_name'][1])) {
$imagefile = addslashes (fread
(fopen ($_FILES["userfile"]["tmp_name"][1], "r"),
filesize ($_FILES["userfile"]["tmp_name"][1])));
$image_name = $_FILES["userfile"]["name"][1];
$image_size = $_FILES["userfile"]["size"][1];
$image_type = $_FILES["userfile"]["type"][1];
$fileName = $_FILES['userfile']['name'][0];
$tmpName = $_FILES['userfile']['tmp_name'][0];
$fileSize = $_FILES['userfile']['size'][0];
$fileType = $_FILES['userfile']['type'][0];
$ext = substr(strrchr($fileName, "."), 1);
$randName = md5(rand() * time());
$filePath = $uploadDir . $randName . '.' . $ext;
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
if (in_array (strtolower ($image_type), $image_types)) {
$sql = "INSERT INTO add (title, addresses, video_dis, subby, displaysub, file_name, file_size, file_type, file_path image_type, image, image_size, image_name, image_date) ";
$sql.= "VALUES ('{$title}', '{$addresses}', '{$video_dis}', '{$subby}', '{$displaysub}', '{$fileName}', '{$fileSize}', '{$fileType}', '{$filePath}', '{$image_type}', '{$imagefile}', '{$image_size}', '{$image_name}', NOW())";
if ($result != true)
{
print "
<META HTTP-EQUIV='Refresh' CONTENT='3; URL=/index.php'>
worked
";
}
}
}
}
html form
<form method="post" enctype="multipart/form-data" action="add.php">
<input type="file" name="userfile[]">
<input type="file" name="userfile[]">
<input type="submit" name="Submit">
and then my add.php
$postdate=date("d/m/y h:i:s"); //create date time
$uploadDir = '/file/';
if ($_FILES)
{
$image_types = Array ("image/bmp",
"image/jpeg",
"image/pjpeg",
"image/gif",
"image/x-png");
if (is_uploaded_file ($_FILES['userfile']['tmp_name'][1])) {
$imagefile = addslashes (fread
(fopen ($_FILES["userfile"]["tmp_name"][1], "r"),
filesize ($_FILES["userfile"]["tmp_name"][1])));
$image_name = $_FILES["userfile"]["name"][1];
$image_size = $_FILES["userfile"]["size"][1];
$image_type = $_FILES["userfile"]["type"][1];
$fileName = $_FILES['userfile']['name'][0];
$tmpName = $_FILES['userfile']['tmp_name'][0];
$fileSize = $_FILES['userfile']['size'][0];
$fileType = $_FILES['userfile']['type'][0];
$ext = substr(strrchr($fileName, "."), 1);
$randName = md5(rand() * time());
$filePath = $uploadDir . $randName . '.' . $ext;
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
if (in_array (strtolower ($image_type), $image_types)) {
$sql = "INSERT INTO add (title, addresses, video_dis, subby, displaysub, file_name, file_size, file_type, file_path image_type, image, image_size, image_name, image_date) ";
$sql.= "VALUES ('{$title}', '{$addresses}', '{$video_dis}', '{$subby}', '{$displaysub}', '{$fileName}', '{$fileSize}', '{$fileType}', '{$filePath}', '{$image_type}', '{$imagefile}', '{$image_size}', '{$image_name}', NOW())";
if ($result != true)
{
print "
<META HTTP-EQUIV='Refresh' CONTENT='3; URL=/index.php'>
worked
";
}
}
}
}