make a loader file contents by code
----- index.php --------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Lector</title>
</head>
<body>
<img src="lector.php" />
</body>
</html>
----- reader.php -------------------------------------
function ConvertToMimeType($fileLocation) {
$MimeTypes = array('audio/aac', 'application/x-abiword', 'application/octet-stream', 'video/x-msvideo', 'application/vnd.amazon.ebook', 'application/octet-stream', 'application/x-bzip', 'application/x-bzip2', 'application/x-csh', 'text/css', 'text/csv', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-fontobject', 'application/epub+zip', 'application/ecmascript', 'image/gif', 'text/html', 'image/x-icon', 'text/calendar', 'application/java-archive', 'image/jpeg', 'image/jpg', 'application/javascript', 'application/json', 'audio/midi', 'video/mpeg', 'application/vnd.apple.installer+xml', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.text', 'audio/ogg', 'video/ogg', 'application/ogg', 'font/otf', 'image/png', 'application/pdf', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-rar-compressed', 'application/rtf', 'application/x-sh', 'image/svg+xml', 'application/x-shockwave-flash', 'application/x-tar', 'image/tiff', 'application/typescript', 'font/ttf', 'application/vnd.visio', 'audio/wav', 'audio/webm', 'video/webm', 'image/webp', 'font/woff', 'font/woff2', 'application/xhtml+xml', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/xml', 'application/vnd.mozilla.xul+xml', 'application/zip', 'video/3gpp', 'audio/3gpp', 'video/3gpp2', 'audio/3gpp2', 'application/x-7z-compressed');
$fileInfo = new finfo(FILEINFO_MIME);
$fileMimeType = $fileInfo->file($fileLocation);
$fileMime = 'application/octet-stream';
if(in_array($fileMimeType, $MimeTypes))
{
$fileMime = $fileMimeType;
}
return $fileMime;
}
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$out = fopen('php://output', 'w'); //output handler
$folderSeparator = '\\';
$path = __DIR__.$folderSeparator;
$fileName = NULL;
$aleatorio = rand(1,2);
if($aleatorio == 1)
$fileName = 'somefile.png';
else
$fileName = 'denegate-access-image.png';
$urlFile = $path.$fileName;
$fileSize = filesize($urlFile);
$handleFile = fopen($urlFile, 'r');
$contents = fpassthru($handleFile);
//other form to do sameting
//$contents = fread($handleFile, $fileSize);
header('Content-disposition: filename="' . $fileName . '"');
header('Pragma: no-cache');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header("Content-type: " . ConvertToMimeType($urlFile));
header("Content-Transfer-Encoding: binary");
header('Content-Length: '.$fileSize);
echo $contents;
//other forms to do sameting
//print file_get_contents($fn);
//fputs($out, $contents); //writing output operation
fclose($out); //closing handler