Exemplo n.º 1
0
 $messages = array();
 for ($i = 0; $i < $uploadsCount; $i++) {
     if ($_FILES["file"]["error"][$i] > 0) {
         $errors[] = i18n_r('ERROR_UPLOAD');
     } else {
         //set variables
         $count = '1';
         $file_base = clean_img_name(to7bit($_FILES["file"]["name"][$i]));
         $file_loc = $path . $file_base;
         //prevent overwriting
         if (!isset($_POST['fileoverwrite']) && file_exists($file_loc)) {
             list($file_base, $filecount) = getNextFileName($path, $file_base);
             $file_loc = $path . $file_base;
         }
         //validate file
         if (validate_safe_file($_FILES["file"]["tmp_name"][$i], $_FILES["file"]["name"][$i])) {
             move_uploaded_file($_FILES["file"]["tmp_name"][$i], $file_loc);
             gs_chmod($file_loc);
             exec_action('file-uploaded');
             // generate thumbnail
             genStdThumb($subFolder, $file_base);
             $messages[] = i18n_r('FILE_SUCCESS_MSG');
             if (requestIsAjax()) {
                 header("HTTP/1.0 200");
                 die;
             }
         } else {
             $messages[] = $_FILES["file"]["name"][$i] . ' - ' . i18n_r('ERROR_UPLOAD');
             if (requestIsAjax()) {
                 header("HTTP/1.0 403");
                 i18n('ERROR_UPLOAD');
Exemplo n.º 2
0
// Include common.php
include 'inc/common.php';
if (!defined('GSIMAGEWIDTH')) {
    $width = 200;
    //New width of image
} else {
    $width = GSIMAGEWIDTH;
}
if ($_POST['sessionHash'] === $SESSIONHASH) {
    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $name = clean_img_name(to7bit($_FILES['Filedata']['name']));
        $targetPath = isset($_POST['path']) ? GSDATAUPLOADPATH . $_POST['path'] . "/" : GSDATAUPLOADPATH;
        $targetFile = str_replace('//', '/', $targetPath) . $name;
        //validate file
        if (validate_safe_file($tempFile, $_FILES["Filedata"]["name"], $_FILES["Filedata"]["type"])) {
            move_uploaded_file($tempFile, $targetFile);
            if (defined('GSCHMOD')) {
                chmod($targetFile, GSCHMOD);
            } else {
                chmod($targetFile, 0644);
            }
            exec_action('file-uploaded');
        } else {
            i18n('ERROR_UPLOAD');
            exit;
        }
        $ext = lowercase(pathinfo($name, PATHINFO_EXTENSION));
        if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'gif' || $ext == 'png') {
            $path = isset($_POST['path']) ? $_POST['path'] . "/" : "";
            $thumbsPath = GSTHUMBNAILPATH . $path;