All pastes #363954 Raw Edit

Stuff

public text v1 · immutable
#363954 ·published 2007-02-19 20:43 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Upload</title>
<style type="text/css">
*{
font-family: Geneva, Arial, Helvetica, sans-serif;
}
</style>
</head>

<body>

<h1>Image Upload</h1>

<?php

if ($_POST['filesubmit'])
{
	$date = date('mdY',time());

	$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/willp/upload/';
	$uploadfile = $uploaddir . $date . '-' . basename($_FILES['userfile']['name']);
	
	echo $uploadfile;

	echo '<div style="width: 500px; margin: auto;">';
	
	if (!preg_match('/[jpg$|gif$|jpe$|jpeg$|png$|doc$]/i',$_FILES['userfile']['name']))
	{
		echo 'Sorry, you must submit either a .gif, .jpg, .jpeg, .jpe, or .png file.';
		echo $_POST['userfile'];
	}
	else
	{	
		if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) 
			{
				echo 'Your file was successfully uploaded.  To insert it into a new snippet, please use the following path:';
				echo '<br /><br />';
				echo '<strong>';
					echo '/admissions/tigersintouch/images/uploads/' . substr($uploadfile,23);
				echo '</strong>';
			}
			else
			{
				echo 'There was a problem when attempting to upload a new picture.';
				echo '<br />';
				echo 'Send the following to the administrator:';
				echo '<br />';
				
				// DEBUGGING INFO
				echo '<pre style="margin-left: 50px; font-weight: bold; text-align: left;">';
					print_r($_FILES);
				echo '</pre>';
			}
		
		echo '</div>';
	}
}
else
{
	echo '<h6 style="margin-bottom: 5px; width: 504px; text-align: left; margin-left: 30px; float: right; font-size: 120%; border-bottom: 1px solid #000;">';
		echo 'Select your file...';
	echo '</h6>';
	
	echo '<span style="width: 465px; display: block; float: right; margin-bottom: 10px; ">';
		echo 'You may only upload GIF, JPG, JPE, JPEG, and PNG files at this time.  If the form immediately fails, you might be trying to upload too large of a file.  The maximum file size allowed is 100kb.  Any files with the same name uploaded on the same day will be <strong>overwritten.</strong>';
	echo '</span>';

	echo '<form enctype="multipart/form-data" action="upload.php" method="post">';
		echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000" />';
		
		echo '<input name="userfile" id="userfile" type="file" size="55" />';
		
		echo '<input class="standard" style="margin-left: 5px;" type="submit" name="filesubmit" value="Upload" />';
	
	echo '</form>';
}

?> 




</body>
</html>