forbidden-type ' ); } // Create the user directory if(!is_dir($content_dir)) { mkdir($content_dir, 0777, true); chmod($content_dir, 0777); } // Create (or re-create) the security file if(!file_exists($security_file)) { file_put_contents($security_file, securityHTML(), LOCK_EX); } // Not already there? (sometimes users upload same file twice, no need to compute it 2 times) $file_first_upload = !file_exists($path); if($file_first_upload) { // File upload error? if(!is_uploaded_file($tmp_filename) || !move_uploaded_file($tmp_filename, $path)) { exit( ' move-error ' ); } } // Resize and compress if this is a JPEG file if(preg_match('/^(jpg|jpeg|png|gif)$/i', $ext)) { // Image thumbnail path $thumb = $content_dir.'/'.$name.'_thumb.'.$ext; $thumb_first_upload = !file_exists($thumb); // Resize only if first time file is uploaded if($file_first_upload) { // Resize the image resizeImage($path, $ext, 1024, 1024); // Copy the image copy($path, $thumb); } // Create the thumbnail (only once) if(!$thumb_first_upload || resizeImage($thumb, $ext, 140, 105, 'square')) { $thumb_xml = ''.htmlspecialchars($location.'store/share/'.$user.'/'.$name.'_thumb.'.$ext).''; } } // Return the path to the file exit( ' '.htmlspecialchars($location.'store/share/'.$user.'/'.$name.'.'.$ext).' '.htmlspecialchars($new_name).' '.htmlspecialchars(getFileMIME($path)).' '.htmlspecialchars(filesize($path)).' '.$thumb_xml.' ' ); } // Bad request error! exit( ' bad-request ' ); ?>