ggalan
09-17-2011, 08:07 PM
i am checking to screen any file that is not a image coming in from a form like this but im getting a Strict Standards message.
can anyone help out on how to avoid this?
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
$uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploaded_files/';
$uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'index.php';
$uploadSuccess = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'index.php';
// name of the fieldname used for the file in the HTML form
$fieldname = 'uploadedfile';// input field name from form
$file = $_FILES[$fieldname];
$allowedExtensions = array("png", "jpg", "jpeg");
function isAllowedExtension($fileName) {
global $allowedExtensions;
return in_array(end(explode(".", $fileName)), $allowedExtensions);//<< Strict Standards: Only variables should be passed by reference
}
if($file['error'] == UPLOAD_ERR_OK) {
if(isAllowedExtension($file['name'])) {
# Do uploading here
echo '1';
} else {
echo "Invalid file type";
}
} else die("Cannot upload");
can anyone help out on how to avoid this?
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
$uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploaded_files/';
$uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'index.php';
$uploadSuccess = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self . 'index.php';
// name of the fieldname used for the file in the HTML form
$fieldname = 'uploadedfile';// input field name from form
$file = $_FILES[$fieldname];
$allowedExtensions = array("png", "jpg", "jpeg");
function isAllowedExtension($fileName) {
global $allowedExtensions;
return in_array(end(explode(".", $fileName)), $allowedExtensions);//<< Strict Standards: Only variables should be passed by reference
}
if($file['error'] == UPLOAD_ERR_OK) {
if(isAllowedExtension($file['name'])) {
# Do uploading here
echo '1';
} else {
echo "Invalid file type";
}
} else die("Cannot upload");