PHP pdf上传文件问题 [英] PHP pdf Upload File Problem
本文介绍了PHP pdf上传文件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?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屋!
查看全文