예제 #1
0
function upload()
{
    // include "file_constants.php";
    $host = "localhost";
    $user = "******";
    $pass = "";
    $db = "counsellor";
    $maxsize = 10000000;
    //set to approx 10 MB
    //check associated error code
    if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
        //check whether file is uploaded with HTTP POST
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            //checks size of uploaded image on server side
            if ($_FILES['userfile']['size'] < $maxsize) {
                //checks whether uploaded file is of image type
                //if(strpos(mime_content_type($_FILES['userfile']['tmp_name']),"image")===0) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                if (strpos(finfo_file($finfo, $_FILES['userfile']['tmp_name']), "image") === 0) {
                    // prepare the image for insertion
                    $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
                    // put the image in the db...
                    // database connection
                    mysql_connect($host, $user, $pass) or die(mysql_error());
                    // select the db
                    mysql_select_db($db) or die("Unable to select db" . mysql_error());
                    // our sql query
                    $sql = "INSERT INTO test_image\n                    (image, name)\n                    VALUES\n                    ('{$imgData}', '{$_FILES['userfile']['name']}');";
                    // insert the image
                    mysql_query($sql) or die("Error in Query: " . mysql_error());
                    $msg = '<p>Image successfully saved in database with id =' . mysql_insert_id() . ' </p>';
                } else {
                    $msg = "<p>Uploaded file is not an image.</p>";
                }
            } else {
                // if the file is not less than the maximum allowed, print an error
                $msg = '<div>File exceeds the Maximum File limit</div>
                <div>Maximum File limit is ' . $maxsize . ' bytes</div>
                <div>File ' . $_FILES['userfile']['name'] . ' is ' . $_FILES['userfile']['size'] . ' bytes</div><hr />';
            }
        } else {
            $msg = "File not uploaded successfully.";
        }
    } else {
        $msg = file_upload_error_message($_FILES['userfile']['error']);
    }
    return $msg;
}
예제 #2
0
function upload()
{
    include "file_constants.php";
    $maxsize = 10000000;
    //set to approx 10 MB
    //check associated error code
    if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
        //check whether file is uploaded with HTTP POST
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            //checks size of uploaded image on server side
            if ($_FILES['userfile']['size'] < $maxsize) {
                //checks whether uploaded file is of image type
                //if(strpos(mime_content_type($_FILES['userfile']['tmp_name']),"image")===0) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                if (strpos(finfo_file($finfo, $_FILES['userfile']['tmp_name']), "image") === 0) {
                    // prepare the image for insertion
                    $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
                    // put the image in the db...
                    // database connection
                    pg_connect('user=js7 host=postgres dbname=meal password=MealAdminOfDoom123') or die("Could not connect: " . pg_last_error());
                    // our PostgreSQL query
                    $result = "INSERT INTO test_image\n                    (img, caption)\n                    VALUES\n                    ('{$imgData}', '{$_FILES['userfile']['name']}');";
                    // insert the image
                    //FIND A WAY TO SET THE IMAGE ID?
                    pg_query($result) or die("Error in Query: " . pg_last_error());
                    $msg = '<p>Image successfully saved in database with id =' . test . ' </p>';
                } else {
                    $msg = "<p>Uploaded file is not an image.</p>";
                }
            } else {
                // if the file is not less than the maximum allowed, print an error
                $msg = '<div>File exceeds the Maximum File limit</div>
                <div>Maximum File limit is ' . $maxsize . ' bytes</div>
                <div>File ' . $_FILES['userfile']['name'] . ' is ' . $_FILES['userfile']['size'] . ' bytes</div><hr />';
            }
        } else {
            $msg = "File not uploaded successfully.";
        }
    } else {
        $msg = file_upload_error_message($_FILES['userfile']['error']);
    }
    return $msg;
}
function _ops_logo_update()
{
    // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
    // of $_FILES.
    if (!isset($_POST['logosite'])) {
        redirect('mgmt_website/website', "error missing logosite value");
    }
    $site = $_POST['logosite'];
    if ($_FILES['logo']['error'] != UPLOAD_ERR_OK) {
        $error_code = $_FILES['logo']['error'];
        redirect('mgmt_website/website', file_upload_error_message($error_code));
    } else {
        $fileName = $site . "-" . $_FILES['logo']['name'];
        //  . '' .$_FILES['logo']['type'];
        move_uploaded_file($_FILES['logo']['tmp_name'], "img/" . $fileName);
        saveSetting("\$SETTINGS_" . $site . "_LOGO", $fileName);
    }
    // _checkCreditials
    redirect('mgmt_website/website', "logo updated");
}
예제 #4
0
function upload()
{
    //check associated error code
    if ($_FILES['image']['error'] == UPLOAD_ERR_OK) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        if (strpos(finfo_file($finfo, $_FILES['image']['tmp_name']), "image") === 0) {
            // prepare the image for insertion
            $imgData = addslashes(file_get_contents($_FILES['image']['tmp_name']));
            $db = new PDO('mysql:host=localhost;dbname=utopia', "root", "");
            $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
            // our sql query
            $sql = $db->prepare("UPDATE user SET picture_data='{$imgData}' WHERE username = '******'username']) . "'");
            $sql->execute();
            $msg = '<p>Profil mis à jour</p>';
        } else {
            $msg = "<p>Le fichier n'est pas une image.</p>";
        }
    } else {
        $msg = file_upload_error_message($_FILES['image']['error']);
    }
    return $msg;
}
예제 #5
0
                 if ($can_delete) {
                     if (!delete_attachment($attach_id)) {
                         message($lang_post['Can\'t delete']);
                     }
                 } else {
                     message($lang_post['No delete']);
                 }
             } else {
                 message($lang_post['No attachments']);
             }
         }
     }
 }
 if (isset($_FILES['attached_file'])) {
     if (isset($_FILES['attached_file']['error']) && $_FILES['attached_file']['error'] != 0 && $_FILES['attached_file']['error'] != 4) {
         error_handler(file_upload_error_message($_FILES['attached_file']['error']), __FILE__, __LINE__);
     }
     if ($_FILES['attached_file']['size'] != 0 && is_uploaded_file($_FILES['attached_file']['tmp_name'])) {
         $can_upload = false;
         if ($panther_user['is_admin']) {
             $can_upload = true;
         } else {
             $data = array(':id' => $id);
             $ps = $db->select('attachments', 'COUNT(id)', $data, 'post_id=:id GROUP BY post_id', 1);
             $num_attachments = $ps->fetchColumn();
             $can_upload = $panther_user['g_attach_files'] == '1' && ($cur_post['upload'] == '1' || $cur_post['upload'] == '') ? true : false;
             if ($can_upload && $num_attachments == $panther_user['g_max_attachments']) {
                 $can_upload = false;
             }
             $max_size = $panther_user['g_max_size'] == '0' && $panther_user['g_attach_files'] == '1' ? $panther_config['o_max_upload_size'] : $panther_user['g_max_size'];
             if ($can_upload && $_FILES['attached_file']['size'] > $max_size) {
예제 #6
0
    ?>
</a></p><?php 
    redirect("admin.php?module=pluckplayer", 5);
} else {
    ?>
<p><b>upload tracks to the music player and delete uploaded tracks.</b></p>

<span class="kop2">upload new track</span><br>
<form method="post" enctype="multipart/form-data">
    <b>Select new track:</b><br>
    <input type="file" name="track"><br><input type="submit" name="action" value="upload">
</form>
<?php 
    if (isset($_FILES["track"])) {
        if ($_FILES["track"]["error"] > 0) {
            print "<p><span style='color: red;'>Upload failed: " . file_upload_error_message($_FILES["track"]["error"]) . ".</span></p>";
        } else {
            $filename = $datadir . $_FILES["track"]["name"];
            if (file_exists($filename)) {
                print "<p><span style='color: red;'>Files: " . $_FILES["track"]["name"] . " already exists!</span></p>";
            } else {
                move_uploaded_file($_FILES["track"]["tmp_name"], $filename);
            }
        }
    }
    ?>
<br>
<span class="kop2">delete uploaded track</span><br><p>
<?php 
    $tracks = 0;
    $music_dir = dir($datadir);
function uploadFile($params)
{
    if (!isset($params['eid'])) {
        return FALSE;
    }
    if (!isset($params['index'])) {
        return FALSE;
    }
    $uploaddir = dirname(__FILE__) . '/upload/' . $params['eid'];
    $return = array();
    if (!file_exists($uploaddir)) {
        if (!@mkdir($uploaddir)) {
            $return['status'] = 'error_noupload';
            $return['error_message'] = 'Could not create upload directory';
        }
    }
    $uploadFileName = time() . '_' . basename($_FILES['Filedata']['name']);
    $uploadfile = $uploaddir . '/' . $uploadFileName;
    if (@move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadfile)) {
        $return['newfilename'] = $uploadFileName;
        $return['status'] = 'success';
    } else {
        $return['status'] = 'error_noupload';
        $return['error_code'] = $_FILES['Filedata']['error'];
        $return['error_message'] = file_upload_error_message($_FILES['Filedata']['error']);
    }
    $return['index'] = $params['index'];
    return $return;
}
 public function upload_image()
 {
     if (!class_exists('Fancy_Product')) {
         require_once FPD_PLUGIN_DIR . '/inc/class-fancy-product.php';
     }
     $product_settings = new FPD_Product_Settings(intval($_POST['product_id']));
     $mb_size = intval(fpd_get_option('fpd_max_image_size'));
     $maximum_filesize = $mb_size * 1024 * 1000;
     foreach ($_FILES as $fieldName => $file) {
         $filename = $file['name'];
         //check if its an image
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
         if (!getimagesize($file['tmp_name']) && $ext !== 'svg') {
             echo json_encode(array('code' => 500, 'message' => __('This file is not an image!', 'radykal'), 'filename' => $file['name']));
             die;
         }
         //check for php errors
         if ($file['error'] !== UPLOAD_ERR_OK) {
             echo json_encode(array('code' => 500, 'message' => file_upload_error_message($file['error']), 'filename' => $filename));
             die;
         }
         //check for maximum upload size
         if ($file['size'] > $maximum_filesize) {
             echo json_encode(array('code' => 500, 'message' => sprintf(__('Uploaded image is too big! Maximum image size is %d MB!', 'radykal'), $mb_size), 'filename' => $filename));
             die;
         }
         //check the minimum DPI
         $dpi = $this->get_image_dpi($file['tmp_name']);
         $min_dpi = fpd_get_option('fpd_minimum_dpi');
         if (isset($dpi[0]) && $dpi[0] !== 0 && $dpi[0] < $min_dpi) {
             echo json_encode(array('code' => 500, 'message' => sprintf(__('The DPI of the uploaded image is too small! Minimum allowed DPI is %d.', 'radykal'), $min_dpi), 'filename' => $filename));
             die;
         }
         //check dimensions
         $image_dimensions = getimagesize($file['tmp_name']);
         $filename = sanitize_file_name($filename);
         $file_path = $this->get_upload_path($filename);
         $filename = basename($file_path);
         if (@move_uploaded_file($file['tmp_name'], $file_path)) {
             $img_url = content_url() . '/uploads/fancy_products_uploads/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $filename;
             echo json_encode(array('code' => 200, 'url' => $img_url, 'filename' => preg_replace("/\\.[^.\\s]{3,4}\$/", "", $filename), 'dim' => $image_dimensions));
         } else {
             echo json_encode(array('error' => 2, 'message' => 'PHP Issue - move_uploaed_file failed', 'filename' => $filename));
         }
     }
     die;
 }
예제 #9
0
파일: fcgi_test.php 프로젝트: sanata-/snail
        if ($error == UPLOAD_ERR_OK) {
            $tmp_name = $val["tmp_name"];
            $name = $val["name"];
            $datafile = "/tmp/test.go";
            move_uploaded_file($tmp_name, $datafile);
            $md5 = md5_file($datafile);
            if ($k0 != $md5) {
                $stat = "FAILED";
                echo "server:err " . $md5 . " != " . $key . "\n";
            }
            $length += strlen($k0) + filesize($datafile);
            unlink($datafile);
            $ret .= $k0 . "(" . strlen($k0) . ") ";
        } else {
            $stat = "FAILED";
            echo "server:file err " . file_upload_error_message($error) . "\n";
        }
    }
    $ret .= "]";
    echo "server:got data length " . $length . "\n";
}
echo "-{$stat}-POST(" . count($_POST) . ") FILE(" . count($_FILES) . ")\n";
function file_upload_error_message($error_code)
{
    switch ($error_code) {
        case UPLOAD_ERR_INI_SIZE:
            return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
        case UPLOAD_ERR_FORM_SIZE:
            return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
        case UPLOAD_ERR_PARTIAL:
            return 'The uploaded file was only partially uploaded';
예제 #10
0
             }
         }
     }
 }
 if ($mode) {
     if ($mode == "enable") {
         conf_mount_rw();
         mark_subsystem_dirty('firmware');
     } else {
         if ($mode == "disable") {
             conf_mount_ro();
             clear_subsystem_dirty('firmware');
         } else {
             if ($mode == "upgrade") {
                 if ($_FILES['ulfile']['error']) {
                     $errortext = "(" . file_upload_error_message($_FILES['ulfile']['error']) . ")";
                 }
                 if (is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
                     /* verify firmware image(s) */
                     if (file_is_for_platform($_FILES['ulfile']['tmp_name'], $_FILES['ulfile']['name']) == false && !$_POST['sig_override']) {
                         $input_errors[] = gettext("The uploaded image file is not for this platform.");
                     } else {
                         if (!file_exists($_FILES['ulfile']['tmp_name'])) {
                             /* probably out of memory for the MFS */
                             $input_errors[] = gettext("Image upload failed (out of memory?)");
                             mwexec("/etc/rc.firmware disable");
                             clear_subsystem_dirty('firmware');
                         } else {
                             /* move the image so PHP won't delete it */
                             rename($_FILES['ulfile']['tmp_name'], "{$g['upload_path']}/firmware.tgz");
                             /* check digital signature */
예제 #11
0
            return 'Failed to write file to disk(not enough space)';
        case UPLOAD_ERR_EXTENSION:
            return 'File upload stopped by extension';
        default:
            return 'Unknown upload error';
    }
}
if ($_POST['pkglocal'] == "PKG1" || $_POST['pkglocal'] == "PKG2") {
    echo $_POST['pkglocal'];
} else {
    echo "<html><body>Error:Select Image1 or Image2</body></html>";
    return 0;
}
$pkgdir = $_POST['pkglocal'];
if ($_FILES['pkgfile']['error'] != 0) {
    echo "<html><body>Error:" . file_upload_error_message($_FILES['pkgfile']['error'] . '</body></html>');
    return 0;
}
if (!stripos($_FILES['pkgfile']['name'], "pkg")) {
    echo "<html><body>Error:File type not PKG</body></html>";
    return 0;
}
if (!is_dir("/tmp/{$pkgdir}")) {
    mkdir("/tmp/{$pkgdir}", 0777);
}
foreach (glob("/tmp/{$pkgdir}/*") as $file) {
    unlink($file);
}
$uploaddir = "/tmp/" . $pkgdir . "/";
$uploadfile = $uploaddir . basename($_FILES['pkgfile']['name']);
move_uploaded_file($_FILES['pkgfile']['tmp_name'], $uploadfile);
예제 #12
0
function upload()
{
    $maxsize = 10000000;
    //set to approx 10 MB
    //check associated error code
    if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
        //check whether file is uploaded with HTTP POST
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            //checks size of uploaded image on server side
            if ($_FILES['userfile']['size'] < $maxsize) {
                //checks whether uploaded file is of image type
                //if(strpos(mime_content_type($_FILES['userfile']['tmp_name']),"image")===0) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                if (strpos(finfo_file($finfo, $_FILES['userfile']['tmp_name']), "image") === 0) {
                    // prepare the image for insertion
                    $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
                    // put the image in the db...
                    // database connection
                    $con = mysqli_connect('localhost', 'shibli', 'shibli') or die(mysqli_error($con));
                    // select the db
                    mysqli_select_db($con, 'piclib') or die("Unable to select db" . mysqli_error($con));
                    // our sql query
                    $ext = get_extension($_FILES['userfile']['name']);
                    $query2 = " Select max(imageID) from imgdata;";
                    $result2 = mysqli_query($con, $query2);
                    $row2 = mysqli_fetch_row($result2);
                    $r = $row2[0] + 1;
                    $sql = "INSERT INTO imgdata values({$r},'{$ext}','{$_POST['imageName']}','{$_POST['user']}','{$imgData}')";
                    header('location: http://localhost:63342/VideoLibraryApp/views/displayLogged.php');
                    // insert the image
                    mysqli_query($con, $sql) or die("Error in Query: " . mysqli_error($con));
                    $msg = '<p>Image successfully saved in database with id =' . mysqli_insert_id($con) . ' </p>';
                } else {
                    $msg = "<p>Uploaded file is not an image.</p>";
                }
            } else {
                // if the file is not less than the maximum allowed, print an error
                $msg = '<div>File exceeds the Maximum File limit</div>
                <div>Maximum File limit is ' . $maxsize . ' bytes</div>
                <div>File ' . $_FILES['userfile']['name'] . ' is ' . $_FILES['userfile']['size'] . ' bytes</div><hr />';
            }
        } else {
            $msg = "File not uploaded successfully.";
        }
    } else {
        $msg = file_upload_error_message($_FILES['userfile']['error']);
    }
    return $msg;
}
예제 #13
0
파일: output.php 프로젝트: skerbis/do-form
 if (isset($element[2]) && $element[2] == 1) {
     $req = $form_required;
 }
 if (isset($element[6]) && trim($element[6]) != '') {
     $upload_MaxSice = trim($element[6]);
 } else {
     $upload_MaxSice = 0;
 }
 if (!empty($_FILES)) {
     if ($_FILES['FORM']['error'][$form_ID]['el_' . $i] === UPLOAD_ERR_OK) {
         // upload ok
     } elseif ($req == '' && $_FILES['FORM']['error'][$form_ID]['el_' . $i] === UPLOAD_ERR_NO_FILE) {
         // upload ok aber keine Datei vorhanden
         $upload_keineDateivorhanden = true;
     } else {
         $error_message .= file_upload_error_message($_FILES['FORM']['error'][$form_ID]['el_' . $i]);
         $warning["el_" . $i] = $form_warn_css;
         $warnblock["el_" . $i] = $form_warnblock_css;
         $warning_set = 1;
     }
     // alexplus: http://forum.redaxo.de/ftopic11635-150.html
     if (!$upload_keineDateivorhanden && $error_message == '') {
         $targetPath = $form_upload_folder;
         $tempFile = $_FILES['FORM']['tmp_name'][$form_ID]['el_' . $i];
         $preTarget = time() . "_" . $_FILES['FORM']['name'][$form_ID]['el_' . $i];
         // Leerzeichen ersetzen durch _
         $targetFile = str_replace(" ", "_", $preTarget);
         $targetPathFile = str_replace('//', '/', $targetPath) . $targetFile;
         // Multimail
         $cupload++;
         $domailfile[$cupload] = $targetFile;
예제 #14
0
 if (!isset($_SESSION['TFU_LAST_UPLOADS']) || isset($_GET['firstStart'])) {
     // we delete the info of the last upload items!
     unset($_SESSION['TFU_LAST_UPLOADS']);
     $_SESSION['TFU_LAST_UPLOADS'] = array();
 }
 $_SESSION['TFU_UPLOAD_REMAINING'] = $_GET['remaining'];
 if ($enable_upload_debug) {
     tfu_debug("3a. \$_FILES content:\n" . print_r($_FILES, true));
 }
 if (count($_FILES) == 0) {
     tfu_debug("ERROR: No file data was found. Most likely the upload failed before the script was executed. Make sure that your server limits can handle the file you tried to upload. Please check the phperror.log for details.");
 } else {
     foreach ($_FILES as $fieldName => $file) {
         // check of the upload error. Only a message is displayed and the upload
         if ($file['error'] != UPLOAD_ERR_OK) {
             tfu_debug('4. ERROR: Php upload error: ' . file_upload_error_message($file['error']));
         } else {
             // we check the uploaded files first because we don't know if it's the flash or any other script!
             if ($enable_upload_debug) {
                 tfu_debug('4. Check valid extension: ' . $file['name']);
             }
             check_valid_extension($file['name']);
             if ($enable_upload_debug) {
                 tfu_debug('4a. Extension valid.');
             }
             $store = 1;
             if (is_supported_tfu_image($file['name'], $file['tmp_name']) && $size < 100000) {
                 // we resize before moving the file to the final destination because maybe the user has some quotas
                 $store = resize_file($file['tmp_name'], $size, $compression, $file['name']);
             }
             if ($store != 0) {
 public function upload_file()
 {
     if (!isset($_POST['albumDir'])) {
         exit;
     }
     $album_dir = trim($_POST['albumDir']);
     check_ajax_referer('fg-upload-nonce', 'security');
     header("Content-Type: application/json");
     if (!file_exists($this->content_dir)) {
         echo json_encode(array('error' => 1, 'message' => __('The directory "' . $this->content_dir . '", where to store the images, does not exist. Please create a new gallery or create this folder by yourself!', 'radykal')));
         die;
     }
     foreach ($_FILES as $fieldName => $file) {
         $filename = $file['name'][0];
         //check if its an image
         if (!getimagesize($file['tmp_name'][0])) {
             echo json_encode(array('error' => 1, 'message' => __('File is not an image', 'radykal'), 'filename' => $filename));
             die;
         }
         //check for php errors
         if ($file['error'][0] !== UPLOAD_ERR_OK) {
             echo json_encode(array('error' => 1, 'message' => __(file_upload_error_message($file['error'][0]), 'radykal'), 'filename' => $filename));
             die;
         }
         //check for maximum upload size
         if ($file['size'][0] > $this->maximum_filesize) {
             echo json_encode(array('error' => 1, 'message' => __('Uploaded image is too big', 'radykal'), 'filename' => $filename));
             die;
         }
         $myFileExt = sanitize_file_name($filename);
         $myTempFile = $this->content_dir . '/' . $album_dir . $myFileExt;
         if (@move_uploaded_file($file['tmp_name'][0], $myTempFile)) {
             chmod($myTempFile, 0755);
             echo json_encode(array('error' => 0, 'filename' => preg_replace("/\\.[^.\\s]{3,4}\$/", "", $filename), 'realFile' => $myFileExt));
         } else {
             echo json_encode(array('error' => 2, 'message' => __('PHP Issue - move_uploaed_file failed', 'radykal'), 'filename' => $filename));
         }
     }
     die;
 }
예제 #16
0
function upload()
{
    include "database/dbco.php";
    $maxsize = 10000000;
    //set to approx 10 MB
    //check associated error code
    if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
        //check whether file is uploaded with HTTP POST
        if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            //checks size of uploaded image on server side
            if ($_FILES['userfile']['size'] < $maxsize) {
                $finfo = finfo_open(FILEINFO_MIME_TYPE);
                //checks whether uploaded file is of image type
                if (strpos(finfo_file($finfo, $_FILES['userfile']['tmp_name']), "image") === 0) {
                    // prepare the image for insertion
                    $imgData = addslashes(file_get_contents($_FILES['userfile']['tmp_name']));
                    // put the image in the db...
                    // database connection
                    $servername = "localhost";
                    $username = "******";
                    $password = "******";
                    $dbname = "ingredients";
                    // Create connection
                    $conn = new mysqli($servername, $username, $password, $dbname);
                    // Check connection
                    if ($conn->connect_error) {
                        die("Connection failed: " . $conn->connect_error);
                    }
                    // our sql query
                    $sql = "INSERT INTO 'storeimages' ('id', 'name', 'image', 'size')\n                    VALUES ('{$_POST['id']}', '{$imgData}', '{$_FILES['userfile']['name']}','{$_FILES['userfile']['size']}');";
                    if ($mysqli->query($sql)) {
                        //echo "New Record has id ".$mysqli->insert_id;
                        echo "<p>uploaded</p>";
                    } else {
                        echo "<p>MySQL error no {$mysqli->errno} : {$mysqli->error}</p>";
                        exit;
                    }
                    mysqli_query($sql) or die("Error in Query insert: " . mysqli_error());
                    // insert the image
                    $msg = '<p>Image successfully saved in database . </p>';
                } else {
                    $msg = "<p>Uploaded file is not an image.</p>";
                }
            } else {
                // if the file is not less than the maximum allowed, print an error
                $msg = '<div>File exceeds the Maximum File limit</div>
                <div>Maximum File limit is ' . $maxsize . ' bytes</div>
                <div>File ' . $_FILES['userfile']['name'] . ' is ' . $_FILES['userfile']['size'] . ' bytes</div><hr />';
            }
        } else {
            $msg = "File not uploaded successfully.";
        }
    } else {
        $msg = file_upload_error_message($_FILES['userfile']['error']);
    }
    return $msg;
}
예제 #17
0
<?php

// This is an example of a script that can be used to receive the config generated by
// NConf, and then deployed by HTTP(s)-POST to a remote server.
$targetdir = "/var/www/NConf_dev_new";
$exec_command = "service restart nagios";
//$exec_command    = "/etc/init.d/sshd status";
$tar = 'tar';
$gunzip = 'gunzip -f';
$execute = !empty($_POST["remote_execute"]) ? $_POST["remote_execute"] : '';
$action = !empty($_POST["remote_action"]) ? $_POST["remote_action"] : '';
// Look for upload error
if ($_FILES['file']['error'] === UPLOAD_ERR_OK) {
    // upload ok
} else {
    echo file_upload_error_message($_FILES['file']['error']);
}
if (is_uploaded_file($_FILES["file"]["tmp_name"])) {
    // do more with the file here
    if (empty($action)) {
        echo '<b>Error</b> Action is not defined, read documentation for details.';
    } elseif ($action == "extract") {
        $target_file_tgz = $targetdir . basename($_FILES["file"]["name"]);
        $target_file_tar = $targetdir . basename($_FILES["file"]["name"], ".tgz") . '.tar';
        // copy
        $status = copy($_FILES["file"]["tmp_name"], $target_file_tgz);
        if (!$status) {
            echo '<b>PHP copy</b> temporary copy(' . $_FILES["file"]["name"] . ', ' . $target_file_tgz . ')';
        }
        // gunzip
        $command = $gunzip . ' ' . $target_file_tgz;