Forum Moderators: coopster
<body>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<div style="padding-bottom:15px; padding-top:20px;">Please select the upload button to upload the weekly pdf file from your PC.</div>
<div style="padding-bottom:10px;"><input name="file" id="file" type="file" /> </div>
<div><input type="submit" value="Upload File" name="uploadBtn" /></div>
</form>
<?php
$current_dir = '/upload/';
$dir = opendir($current_dir);
$upfile = $current_dir.$_FILES['file']['name'];
if ($_FILES['file']['error'] > 0)
{echo 'Problem: ';
switch ($_FILES['file']['error'])
{
case 1: echo 'File exceeded upload_max_filesize'; break;
case 2: echo 'File exceeded max_file_size'; break;
case 3: echo 'File only partially uploaded'; break;
case 4: echo 'No file uploaded'; break;
}
exit;
}
else echo 'File uploaded successfully';
?>
</body>
if(isset($_POST['file'])){
$current_dir = '/upload/';
$dir = opendir($current_dir);
$upfile = $current_dir.$_FILES['file']['name'];if ($_FILES['file']['error'] > 0){
echo 'Problem: ';
switch ($_FILES['file']['error']){
case 1: echo 'File exceeded upload_max_filesize'; break;
case 2: echo 'File exceeded max_file_size'; break;
case 3: echo 'File only partially uploaded'; break;
case 4: echo 'No file uploaded'; break;
}
exit;
}
else{
echo 'File uploaded successfully';
}
}
elseif($_FILES['file']['error'] == 0 && isset($_POST['file']) ){
echo 'File uploaded successfully';
}