I am having trouble getting my file upload to work. Up to now it has been working good, I recently had to upload a backup version of my website to the online server, but now the upload script does not work and, I suspect it may be a file upload permissions issue.
I understand I may have to inherit the folder/file permissions and ownership from my local host to the host server, but I not sure how to do this.
I cannot upload PDF files and/or images from the admin section upload form, but I can upload the files and/or images to the uploads folder by using either Filezilla FTP or by using the Cpanel File Upload with success.
I do not get any error message in the site admin upload form when submitting the form data, and the file/s in question are not present in the uploads folder or images folder.
The host server uploads folder permissions have been set at 0755, and the files permissions are set at 0644 in cPanel.
Nothing happens, and up until now everything worked ok. I have checked the script but I am not sure if everything is correct or not. It appears to be happening on all file uploads from the site admin file upload form.
I need file and/or image upload options in the admin panel for the site admin users to operate.
Can someone help me please? See below for example files:
upload_file.php - (for pdf & doc uploads):
<?php
session_start();
//Must go through login and be Admin
if(!$_SESSION['loggedIn']) {
header('Location: index.php');
}
$title = 'Upload File';
require_once('template/header.php');
require_once('template/connect.php');
?><br /><br /><br /><br />
<div id="uploadFile">
<div id="uploadFiles">
<?php
$target = "uploads/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size >2950000){
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php"){
echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0){
echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else {
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)){
echo "              
                   
The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
// else {
// echo "Sorry, there was a problem uploading your file.";
//}
}
?>
</div>
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
<fieldset>
<legend> Upload File | <a href="viewFile.php" class="apageLinks">View File List</a> | 
<a href="menu.php" class="apageLinks">Main Menu</a> | 
<a href="logout.php" class="apageLinks">Log out</a> 
</legend><br /><br />
Please choose a file:<input name="uploaded" type="file" /><br /><br />
<input name="submit" type="submit" value="Submit" class="form" /><br />
</fieldset>
</form><br /><br /><br /><br /><br />
</div>
<!-- End of page content -->
</div>
</body>
</html> It is a simple file upload script that I use to upload PDF files to the server. the files should be uploaded to the uploads folder in the admin section of the website, and these files are generally small in size, in fact I also use a similar script to upload images to the host sevrer.