I don't manage to understand why the code below gives me this error: Strict Standards: Only variables should be passed by reference in /web/htdocs/www.mywebsite.com/admin/post/upload.php on line 8
Anyway, the result is successful! (it gives me "Success" and actually works) How could I fix it?
Sorry for my english, thank you in advance!
The line 8 is: $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
The whole code is:
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
$expensions= array("jpeg","jpg","png","pdf");
if(in_array($file_ext,$expensions)=== false){
$errors[]="Error. Supported formats: JPG, JPEG, PNG, PDF";
}
if($file_size > 999999999) {
$errors[]='File too large';
}
if(empty($errors)==true) {
move_uploaded_file($file_tmp,"../../../sources/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<form action = "" method = "POST" enctype = "multipart/form-data">
<input type = "file" name = "image" />
<input type = "submit"/>
<ul>
<li>Filename: /press/sources/<?php echo $_FILES['image']['name']; ?>
<li>Size: <?php echo $_FILES['image']['size']; ?>
<li>Format: <?php echo $_FILES['image']['type'] ?>
</ul>
</form>
</body>
</html>