I am using the same feature move_uploaded_file($source, $destnation); but i am unable to move the files from database to server.
<?php require_once('Connections/file_upload.php'); ?>
<?php
$in_time = $_FILES['in_time']['name'];
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form0")) {
move_uploaded_file ($_FILES['in_time']['tmp_name'],"/demo_upload/uploads/{$in_time}");
$insertSQL = sprintf("INSERT INTO demo_photo_taking (week, `date`, client, brand, store_code, in_time) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['week'], "text"),
GetSQLValueString($_POST['date'], "date"),
GetSQLValueString($_POST['CLient'], "text"),
GetSQLValueString($_POST['Brand'], "text"),
GetSQLValueString($_POST['Store_Code'], "int"),
GetSQLValueString($_POST['in_time'], "text"));
mysql_select_db($database_file_upload, $file_upload);
$Result1 = mysql_query($insertSQL, $file_upload) or die(mysql_error());
$insertGoTo = "index.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_file_upload, $file_upload);
$query_Recordset1 = "SELECT * FROM demo_photo_taking";
$Recordset1 = mysql_query($query_Recordset1, $file_upload) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form method="POST" action="<?php echo $editFormAction; ?>" name="form0" >
<input type="week" name="week"><br/><br/>
<input type="date" name="date"><br/><br/>
<label>Clients</label><br/>
<input type="text" name="CLient"><br/><br/>
<label>Brands</label><br/>
<input type="text" name="Brand"><br/><br/>
<label>Store Code</label><br/>
<input type="text" name="Store_Code"><br/><br/>
<input type="file" name="in_time" id="in_time"><br/>
<input type="submit" value="upload">
<input type="hidden" name="MM_insert" value="form0">
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
I even tried Copy function but still i cannot move the file from the database to the server. Kindly help me to fix the problem.
Aucun commentaire:
Enregistrer un commentaire