require ("includes/functions.php");
require ("includes/config.php");
require ("includes/upload.class.php");
require ("includes/imagesimple.class.php");
// admin filter
if($_COOKIE["admin"] == $password) $admin=true;else $admin=false;
$input_field_name = "picturefile";
$accepted_mime_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/pjpeg');
$destination_folder = "images/";
$overwrite = false; //Overwrite the file if it exists
$upload = new upload($input_field_name);
/**
* The following three lines are optional.
* They set some upload-limits.
*/
$upload->set_max_file_size(5120000);
$upload->set_max_image_size(2048, 1536); //in pixels
$upload->set_accepted_mime_types($accepted_mime_types);
//$upload->draw_form('Upload pictures', 'index.php'); //the second argument is optional
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $admin){
$result = $upload->move($destination_folder, $overwrite);
echo '';
if ($result == true){
$da_file = $destination_folder."/".$upload->file['name'];
chmod ($da_file, 0644);
echo $upload->file['name']." was successfully uploaded | ";
if ($_POST['dothumb'] == "y") {
$thumb = new image($da_file);
$thumb->Resize(640, 480);
$thumbname = $thumb->WriteFile($destination_folder."/", "_thumb");
if (file_exists($destination_folder."/".$thumbname)) {
echo $thumbname." was successfully Created
";
}
}
echo '
';
$wiki_image = "[((images/".$thumbname."))|images/".$upload->file['name']."?]";
echo 'Pour afficher l\'image sur une page : '.$wiki_image;
?>
} else {
echo "" . $upload->error_msg . "";
}
}
?>