there. I'm not very experienced with PHP, but I've been charged with modifying a site that is very heavy in PHP. Part of the functionality is uploading an image and having it display on the page. I have gotten the image name to write to the database and the image HTML to display when the database field is not empty. However, I cannot figure out how to get the image to save to the server. Any help would be greatly appreciated!
HTML:
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label for="logo">Primary Logo Upload:</label> <input type="file" id="logo" name="logo" class="fullWidth" ><br>
<input type="submit" value="Save Changes">
<input type="hidden" name="logo" value="<?php echo $row_RecordsetCity['logo']; ?>" />
</form>
PHP:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$location = $_FILES['logo'];
$image = rand(1,2);
$image = $image * time();
$image = $image."-lp".".jpg";
$filename = $image;
$path="./_citylogo/logo/".$filename;
$tempname=$location['tmp_name'];
copy($tempname,$path);
if ($location['name'] == "") {
$_POST['logo'] = $_POST['logo'];
} else {
$_POST['logo'] = $image;
}
}
<?php error_reporting(E_ALL); ini_set('display_errors', 1);then the rest of your code, to see if it yields anything.$path="./_citylogo/logo/".$filename;is writable