尝试上传到000WebHost数据库,但不上传

时间:2017-01-09 19:34:11

标签: php html file-upload webserver

我试图在我的网络主机数据库中上传pdf文件,但它不起作用。 我有一个php文件: upload.php

<form action="<?php print $PHP_SELF?>" enctype="multipart/form-data" method="post">
   Last name:<br /> <input type="text" name="name" value="" /><br />
   class notes:<br /> <input type="file" name="classnotes" value="" /><br />    
  <input type="submit" name="submit" value="Submit Notes" />
</form>

<?php
    define ("filesplace","uploads/"); //uploads is the folder in my server database 

    if (is_uploaded_file($_FILES['classnotes']['tmp_name'])) {

    if ($_FILES['classnotes']['type'] != "application/pdf") {
      echo "<p>Class notes must be uploaded in PDF format.</p>";
   } else {
      $name = $_POST['name'];
      $result = move_uploaded_file($_FILES['classnotes']['tmp_name'], filesplace."/$name.pdf");
  if ($result == 1) echo "<p>Upload done .</p>";
  else echo "<p>Sorry, Error happened while uploading . </p>";
    } 
  } 
?>

它显示文件正在上传,但最后显示错误消息:抱歉,上传时出错

文件upload.php具有所有权限(777)以及上传文件夹。 我是000Webhost的免费客户,这可能是个问题? 你能帮我解决这个问题吗? :d

0 个答案:

没有答案