Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving trouble uploading a file
    primarykey
    data
    text
    <p>I am having trouble uploading a file. First of all I have a class:</p> <pre><code>class upload { private $name; private $document; public function __construct($nme,$doc) { $this-&gt;setName($nme); $this-&gt;setDocument($doc); } public function setName($nme) { $this-&gt;name = $nme; } public function setDocument($doc) { $this-&gt;document = $doc; } public function fileNotPdf() { /* Was the file a PDF? */ if ($this-&gt;document['type'] != "application/pdf") { return true; } else { return false; } } public function fileNotUploaded() { /* Make sure that the file was POSTed. */ if (!(is_uploaded_file($this-&gt;document['tmp_name']))) { return true; } else { return false; } } public function fileNotMoved($repositry) { /* move uploaded file to final destination. */ $result = move_uploaded_file($this-&gt;document['tmp_name'], "$repositry/$this-&gt;name.pdf"); if($result) { return false; } else { return true; } } } </code></pre> <p>Now for my main page:</p> <pre><code>$docName = $_POST['name']; $page = $_FILES['doc']; if($_POST['submit']) { /* Set a few constants */ $filerepository = "np"; $uploadObj = new upload($docName, $page); if($uploadObj-&gt;fileNotUploaded()) { promptUser("There was a problem uploading the file.",""); } elseif($uploadObj-&gt;fileNotPdf()) { promptUser("File must be in pdf format.",""); } elseif($uploadObj-&gt;fileNotMoved($filerepository)) { promptUser("File could not be uploaded to final destination.",""); } else { promptUser("File has been successfully uploaded.",""); } } </code></pre> <p>The errors that I get:</p> <blockquote> <p><strong>Warning:</strong> move_uploaded_file(about.pdf)[function.move-uploaded-file]: failed to open stream: No such file or directory in...</p> <p><strong>Warning:</strong> move_uploaded_file()[function.move-uploaded-file]: Unable to move 'c:\xampp\tmp\php13.tmp' to 'about.pdf' in...</p> <p>File could not be uploaded to final destination.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload