PHP pdf上传文件问题 [英] PHP pdf Upload File Problem

查看:286
本文介绍了PHP pdf上传文件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

交易所有我在我的网站上有一些问题。我试图上传pdf文件,但它不会存储在我的database.pdf文件大小约4.5MB.here与iam发布我的代码。请给我解决方案和错误在哪里。



 <?php  

ob_start();

session_name( berendinaadmin);
session_regenerate_id();
session_start();

包括' inc / check_loged.php';
包括' ../inc / db.inc.php';

$ load = $ mysqli-> query( SELECT * FROM publication);


if(isset($ _ POST [' add' ]))
{

$ type = $ _ POST [' type'< /跨度>];
$ year = $ _POST [' year ];

if($ _ FILES [' file'] [ type']!= ' application / pdf'
{
$ alert = ' < strong class =alert alert-danger>请上传PDF文件< / strong>';
}

else
{

$ check = $ mysqli-> query( SELECT * FROM publication WHERE year ='$ year 'AND type ='$ type');

if($ check-> num_rows> 0)
{
$ alert = ' < strong class =alert alert-danger>记录exsits< / strong>';
}
else
{

$ path = ' ../ publications /'。$ _ FILES [' file'] [' 名称];
move_uploaded_file($ _ FILES [' file'] [' tmp_name'],$ path);

$ mysqli-> query( INSERT INTO publication VALUES('','$年, '$路径', '$类型'));
$ alert = ' < strong class =alert alert-success>已成功上传< /强>';
}

}




}
? >

解决方案

load =


mysqli->查询(< span class =code-string> SELECT * FROM publication);


if(isset(


_POST [' add']))
{


Deal all i had some problem in my web site.i tried to upload the pdf file but it is not going to store in my database.pdf file size around 4.5MB.here with iam publish the my code.please give me the solution and where is the error.

<?php

    ob_start();

    session_name("berendinaadmin");
    session_regenerate_id();
    session_start();

    include 'inc/check_loged.php';
    include '../inc/db.inc.php';

    $load=$mysqli->query("SELECT * FROM publication");


    if(isset($_POST['add']))
    {

        $type=$_POST['type'];
        $year =  $_POST['year'];

        if($_FILES['file']['type']!='application/pdf')
        {
            $alert='<strong class="alert alert-danger">Please upload a PDF file</strong>';
        }

        else
        {

            $check = $mysqli->query("SELECT * FROM publication WHERE year='$year' AND type='$type'");

            if($check->num_rows>0)
            {
                $alert = '<strong class="alert alert-danger">The record exsits</strong>';
            }
            else
            {

                $path ='../publications/'.$_FILES['file']['name'];
                move_uploaded_file($_FILES['file']['tmp_name'],$path);

                $mysqli->query("INSERT INTO publication VALUES('','$year','$path','$type')");
                $alert='<strong class="alert alert-success">Successfully Uploaded </strong>';
            }

        }




    }
?>

解决方案

load=


mysqli->query("SELECT * FROM publication"); if(isset(


_POST['add'])) {


这篇关于PHP pdf上传文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆