can someone please help me? i've tried to seek help in multiple forums and i've been reading previous posts and as much info as i can online and i am still coming up with the same result: no file added to my directory.
does anyone see what i'm doing wrong? thank you!
Code: Select all
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
// error array
$error = array();
// define a constant for the maximum upload size
define ('MAX_FILE_SIZE', 51200);
// define constant for upload folder
$uploadDIR = '/home/jhgroup/domains/mysite.com/public_html/upload';
// replace any spaces in original filename with underscores
// at the same time, assign to a simpler variable
$file = $_FILES['image_data']['name'];
str_replace(' ', '_', '/', $file);
$fileTemp = $_FILES['image_data']['tmp_name'];
$randomfilename = sha1($file);
$filename = $randomfilename.$file;
// convert the maximum size to KB
$max = number_format(MAX_FILE_SIZE/1024, 1).'KB';
// create an array of permitted MIME types
$permitted = array('image_data/gif', 'image_data/jpeg', 'image_data/pjpeg', 'image_data/png');
// begin by assuming the file is unacceptable
$sizeOK = false;
$typeOK = false;
// check that file is within the permitted size
if ($_FILES['image_data']['size'] > 0 && $_FILES['image_data']['size'] <= MAX_FILE_SIZE) {
$sizeOK = true;
}
// check that file is of a permitted MIME type
foreach ($permitted as $type) {
if ($type == $_FILES['image_data']['type']) {
$typeOK = true;
break;
}
}
if ($sizeOK && $typeOK) {
move_uploaded_file($fileTemp, '$uploadDIR/$filename');
}