dozxos6346 2016-07-20 08:40
浏览 32
已采纳

move_uploaded_file正在localhost中工作,但不在服务器中

I'm using move_uploaded_file to transfer some files that I selected to the other folder. It's working on my localhost but not in our server. I don't know why. Here are my codes.

   <?php
     include('connect.php');
     if(isset($_POST['submit']))
     {
       $position = $_POST['position'];
       $first_name = $_POST['first_name'];
       $last_name = $_POST['last_name'];
       $contact_number = $_POST['contact_number'];
       $email = $_POST['email'];
       $status = 'NO';

       $resume = $_FILES['resume']['name'];
       $resume_tmp = $_FILES['resume']['tmp_name'];
       $ret=explode('.',$_FILES['resume']['name']);
       $file_ext=array_pop($ret);
       $extensions = array("pdf","docx");

       if(in_array($file_ext,$extensions )=== false){
        echo "<script> alert('Unsupported format')</script>";
        echo "<script>window.location='index.php';</script>";
       }
       else{    
            move_uploaded_file($resume_tmp,"resume/$resume");
            $query=$pdo->prepare("INSERT INTO                   applicants(position,first_name,last_name,contact_number,email,resume,status) VALUES (:position,:first_name,:last_name,:contact_number,:email,:resume,:status)");
            $query->bindParam(':position',$position);
            $query->bindParam(':first_name',$first_name);
            $query->bindParam(':last_name',$last_name);
            $query->bindParam(':contact_number',$contact_number);
            $query->bindParam(':email',$email);
            $query->bindParam(':resume',$resume);
            $query->bindParam(':status',$status);
            $query->execute();

            echo "<script> alert('You Successfully Applied to this Job')</script>";
            echo "<script>window.location='index.php';</script>";
      }   
      }
    ?>
  • 写回答

2条回答 默认 最新

  • dongxing9219 2016-07-30 11:19
    关注

    First check if upload directory exist or not. and then change its permission 777 all writable.

    $file = "images";
    if(is_dir($file))
    {
    echo ("$file is a directory");
    }
    else
    {
    echo ("$file is not a directory");
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类