Hi,
I have created a basic image upload for a content management system and I have used this format on a few different sites and made them live without any issue.
The problem I have now come across is this, the code I use works on my testing server and other hosting servers but on the one my client has all information is uploaded to the database fine but the actual image file is not being upplaoded to the directory.
The only difference I can see with the hosting is that this is running PHP 5.2.13 and my testing server is running 5.2.9-2. I have included the basic code below if anyone can shed any light on this I would be eternally gratefull as it is driving me insane!
$editFormAction = $_SERVER[‘PHP_SELF’];
if (isset($_SERVER[‘QUERY_STRING’])) {
$editFormAction .= “?” . htmlentities($_SERVER[‘QUERY_STRING’]);
}
if ((isset($_POST[“MM_insert”])) && ($_POST[“MM_insert”] == “form1”)) {
$insertSQL = sprintf(“INSERT INTO projects (header, copy, image) VALUES (%s, %s, %s)”,
GetSQLValueString($_POST[‘header’], “text”),
GetSQLValueString($_POST[‘copy’], “text”),
GetSQLValueString($_FILES[‘image’][‘name’], “text”));
mysql_select_db($database_standard, $standard);
$Result1 = mysql_query($insertSQL, $standard) or die(mysql_error());
$insertGoTo = "list_projects.php";
if (isset($_SERVER[‘QUERY_STRING’])) {
$insertGoTo .= (strpos($insertGoTo, ‘?’)) ? “&” : “?”;
$insertGoTo .= $_SERVER[‘QUERY_STRING’];
}
header(sprintf(“Location: %s”, $insertGoTo));
}
if (array_key_exists(‘upload’, $_POST)) {
// define constant for upload folder
define(‘UPLOAD_DIR’, ‘gal_img/’);
// move the file to the upload folder and rename it
move_uploaded_file($_FILES[‘image’][‘tmp_name’], UPLOAD_DIR.$_FILES[‘image’][‘name’]);
}
?>