【问题标题】:How to save file on other server disk using PHP如何使用 PHP 将文件保存在其他服务器磁盘上
【发布时间】:2022-11-21 06:09:12
【问题描述】:

我在使用 php 保存文件时遇到问题。我尝试做类似 mediafire 或 google drive 的事情。 它是路径变量的代码:

    $dir = "../src/users/$name/";

有我的代码:

<?php 
  session_start();
  include "../src/db_conn.php";

  if(isset($_SESSION['login'])) {
    $name = $_SESSION['login'];
    $dir = "../src/users/$name/";
    $file = $dir.basename($_FILES['file']['name']);
    $imageFileType = strtolower(pathinfo($file,PATHINFO_EXTENSION));
    $upload = 1;

    if(file_exists($file)) { 
      header("Location: ../index.php?error=Sorry, file already exsist.");
      $upload = 0;
    }

    if($_FILES['file']['size'] > 500000) {
      header("Location: ../index.php?error=Sorry, your file is too large.");
      $upload = 0;
    }

    if($upload == 0) {
      header("Location: ../index.php?error=Sorry, your file was not uploaded.");
      exit();
    }else {
      if(move_uploaded_file($_FILES['file']['tmp_name'], $file)) {
        header("Location: ../index.php?success=File " . htmlspecialchars( basename( $_FILES['file']['name'])). " has been uploaded");
        exit();
      } else {
        header("Location: ../index.php?error=There was and error uploading your file.");
      }
    }
  }
?> 

这可行,但我无法在其他服务器上保存文件...

【问题讨论】:

    标签: php web file-upload server disk


    【解决方案1】:

    我有同样的问题。 请帮助某人!

    【讨论】:

      猜你喜欢
      • 2011-03-26
      • 2012-12-18
      • 2011-12-26
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多