コード例 #1
0
ファイル: attach.php プロジェクト: BGCX067/f2cont-svn-to-git
			return false;
		}
	}

-->
</script>
<?php 
//保存数据
if ($action == "save") {
    if (count($_FILES) == 1) {
        $attachment_file = $_FILES["attfile"]["tmp_name"];
        $path = "../attachments/month_" . date("Ym");
        $fileName = $_FILES["attfile"]["name"];
        $fileSize = $_FILES["attfile"]["size"];
        $info = $fileName . " (" . formatFileSize($fileSize) . ")";
        if (!checkFileSize($fileSize)) {
            print_message($strAttachmentsError1 . formatFileSize($cfg_upload_size));
        } else {
            $attachment = upload_file($attachment_file, $fileName, $path);
            if ($attachment == "") {
                print_message($strAttachmentsError);
            } else {
                $value = "month_" . date("Ym") . "/" . $attachment;
                do_filter("f2_attach", "../attachments/" . $value);
                //写进数据库
                $fileType = getFileType($fileName);
                if ($imageAtt = @getimagesize($path . "/" . $attachment)) {
                    $fileWidth = $imageAtt[0];
                    $fileHeight = $imageAtt[1];
                } else {
                    $fileWidth = 0;
コード例 #2
0
}
if (!empty($time)) {
    echo "Photo already uploaded for that show";
    exit;
}
if (!empty($_FILES["up_file"]) && $_FILES['up_file']['error'] == 0) {
    echo "found a file!";
    //echo "dirname:".dirname(__FILE__);
    //  exit();
    //Check if the file is JPEG image and it's size is less than 500Kb
    $filename = basename($_FILES['up_file']['name']);
    $ext = substr($filename, strrpos($filename, '.') + 1);
    // allow other extensions: png, gif, jpeg
    //  if (($ext == "jpg") && ($_FILES["up_file"]["type"] == "image/jpeg") &&
    //    ($_FILES["up_file"]["size"] < 500000)) {
    if (checkExtension($ext) && checkFileSize()) {
        $fname = $sdate . "_" . $u . "." . $ext;
        $newname = dirname(__FILE__) . '/tmp/' . $fname;
        echo $newname;
        //Check if the file with the same name is already exists on the server
        if (!file_exists($newname)) {
            //Attempt to move the uploaded file to it's new place
            if (move_uploaded_file($_FILES['up_file']['tmp_name'], $newname)) {
                echo "File has been submitted!";
            } else {
                echo "Error: A problem occurred during file upload!";
                exit;
            }
        } else {
            echo "Error: Photo from user " . $u . " from the show on " . $sdate . " already exists";
            exit;