All pastes #905761 Raw Edit

Something

public php v1 · immutable
·published 2008-02-16 00:31 UTC
rendered paste body
<?php//this will check to make sure the uploaded file actually exists $maxsize=15000;if (!$HTTP_POST_VARS['submit']) {  //print_r($HTTP_POST_FILES);  $error=" ";//this will cause the rest of the processing to be skipped//and the upload form displays}if (!is_uploaded_file($HTTP_POST_FILES['upload_file']['tmp_name']) AND!isset($error)) {  $error = "<b>You must try to upload the file again!</b><br><br>";  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);}//this will check the size and make sure it is not bigger than $maxsizeif($HTTP_POST_FILES['upload_file']['size'] > $maxsize AND !isset($error)) {  $error = "<b>Error, file must be less than $maxsize bytes. </b><br><br>";  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);}//this will check to make sure the file is only a .txt fileif($HTTP_POST_FILES['upload_file']['type'] != "text/txt" AND !isset($error)) {  $error = "<b>You may only upload .txt files.</b><br><br>";  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);}//the uploaded file has passed all checks, we will now proceed to mv the file on//it will copy it from a /tmp folder to the /var/ww/html/uploads/ dirif (!isset($error)) {copy($HTTP_POST_FILES['upload_file']['tmp_name'],"/var/www/html/uploads/".$HTTP_POST_FILES['upload_file']['name']);  unlink($HTTP_POST_FILES['upload_file']['tmp_name']);  print "Thank you for your upload.";  exit;}else {  echo ("$error");}?><html><head></head><body><form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">Choose a file to upload:<br><input type="file" name="upload_file" size="80"><br><input type="submit" name="submit" value="submit"></form></body></html>