HI, I am relatively new to php and am attempting to have an uploaded file to saved into the Images folder. However whilst the entry is input correctly into the database, the image itself is not uploaded. I am using 1and1. Below is my php.ini:
register_globals = 0
allow_url_fopen = 1
session.bug_compat_warn = 0
memory_limit = 128M
max_execution_time=3600
post_max_size = 128M
upload_max_filesize= 128M
upload_tmp_dir = '/temp'
And below is my PHP code:
<?php
include ('connection.php');
session_start();
$pic=$HTTP_POST_FILES['previewImage']['tmp_name'];
$destination='/Images';
$date = date('d-m-Y');
$postarticle = "INSERT INTO articles VALUES (NULL,'$_POST[title]',CURDATE(), '{$_SESSION['ID']}','Images/$_POST[previewImage]', '$_POST[preview]', '$_POST[video]', '$_POST[content]', '$_POST[additionalInformation]', '$_POST[type]')";
if (mysql_query($postarticle,$conn)){
move_uploaded_file($pic,$destination.$HTTP_POST_FILES['previewImage']['name']);
header("Location: index.php");
}
else
{
header("Location: {$_SERVER['HTTP_REFERER']}");
}
?>
Hope someone can find the solution 🙂