如何使用PHP上传zip / rar或任何压缩文件

时间:2018-07-07 04:54:50

标签: php

这很简单。我在php中创建了一个表格,仅上传zip / rar或任何压缩文件并发送到我的服务器。这已成功发送,但这是我的问题:我无法打开zip / rar或任何压缩文件,并且显示消息“访问被拒绝”。这是我的代码。

date_default_timezone_set('Asia/Kolkata'); //you can add your own timezone
$host = 'localhost';
$user = 'your_db_username';
$pass = 'your_db_password';
$db = 'autosave';
$conn = new mysqli($host, $user, $pass, $db);
function insertPost($title,$content, $conn){
  $sql = "INSERT INTO post VALUES(null, ?, ?)";
  $stmt = $conn->stmt_init();
  if($stmt->prepare($sql)){
    $stmt->bind_param('ss',$title,$content);
    if($stmt->execute()){
      echo $conn->insert_id;
    }
  }}

function updatePost($title,$content,$id, $conn){
  $sql = "UPDATE post SET title = ?, content = ? WHERE id = ?";
  $stmt = $conn->stmt_init();
  if($stmt->prepare($sql)){
    $stmt->bind_param('ssi',$title,$content,$id);
    if($stmt->execute()){
      echo "<i>Draft Saved at ".date("h:i:s a")."</i>";
    }
  }}
if(isset($_GET['save'])){
  $title = $_POST['title'];
  $content = $_POST['content'];
  $id = $_POST['id'];
  if($id != ''){
    updatePost($title, $content,$id, $conn);
  }
  else{
    insertPost($title, $content, $conn);
  }}
?>

我应该怎么办?

0 个答案:

没有答案