Reputation: 1355
I am having trouble uploading a file to my server. I am using another computer on my network at act as my server running Linux using Apache. I am trying to upload pdf files to my server but no matter what size or the name of the file I can not get a file to upload. When I echo $_SERVER['DOCUMENT_ROOT']
I get /var/www
. My folder structured would be var/www/phpfiles/uploads
. The files addentry.php
, phpupload.php
and test.php
are all in this path var/www/phpfiles
.
When I upload a file I get the correct file name, size and tmp echoed, but I do not get "Uploaded" or "Root Uploaded" echoed, and the file is not moved to var/www/phpfiles/uploads
. Any help would be greatly appreciated.
addentry.php
<div id="uploadPDF">
<iframe id="iframe_display" src="test.php" width="400" height="100">
</iframe>
</div>
phpupload.php
$tempName = $_POST[instrumentPDF];
$fileSize = $_FILES['instrumentPDF']['size'];
$fileType = $_FILES['instrumentPDF']['type'];
$fileName = $_FILES['instrumentPDF']['name'];
$tmp_name = $_FILES['instrumentPDF']['tmp_name'];
echo ("file size: " . $fileSize . "<br>");
echo ("<br>");
echo ("file name: " . $fileName . "<br>");
echo ("<br>");
echo ("pdf Test: " . $pdfTest . "<br>");
echo ("<br>");
echo ("pdf Temp_Name: " . $tmp_name . "<br>");
if(move_uploaded_file($tmp_name, "uploads/" . $fileName)){
echo ("<br>");
echo ("Uploaded");
echo ("<br>");
}
if(move_uploaded_file($tmp_name, $_SERVER['DOCUMENT_ROOT']."/uploads/".$fileName)){
echo ("<br>");
echo ("Root Uploaded");
echo ("<br>");
}
test.php
<form enctype="multipart/form-data" method="POST" action="phpupload.php" name="aform" id="PDFform">
<table width="300" height="25" border="1">
<tr>
<td><label>Instrument (only pdf)</label> <input type="hidden" name="MAX_FILE_SIZE" value="104857600" /></td>
<td><input name="instrumentPDF" type="file" onchange="check_file()"/></td>
</tr>
<tr>
<td> </td>
<td><input name="Submit" type="Submit" align="absmiddle" /></td>
</tr>
</table>
</form>
Upvotes: 0
Views: 17123
Reputation: 324
I agree with Adidi - it usually has to do with permissions. Here is another post about what permissions are proper for a folder that allows uploads: What are the proper permissions for an upload folder with PHP/Apache?
Upvotes: 1