Public feed #602233

Unnamed

public text v1 · immutable
Raw Edit
·published 2007-07-03 23:32 UTC
rendered paste body
<?php
if(isset($_POST['start_upload']) && $_POST['txt_file'] != ""){
   $local_file = $_POST['txt_file']; // Defines Name of Local File to be Uploaded
	list($var1, $var2,) = split('[.]', $local_file);
	$fname = $_POST['year'].".".$var2;
	$destination_file = "./common/image/potw/year".$fname;  // Path for File Upload (relative to your login dir)
	echo $local_file;
	echo $destination_file;

	if (($_FILES['txt_file']['type'] == "image/gif")		|| 
		($_FILES['txt_file']['type'] == "image/jpeg")		|| 
		($_FILES['txt_file']['type'] == "image/png")		|| 
		($_FILES['txt_file']['type'] == "image/bmp")		|| 
		($_FILES['txt_file']['type'] == "image/x-bmp")		||
		($_FILES['txt_file']['type'] == "image/x-win-bmp")	||
		($_FILES['txt_file']['type'] == "image/x-windows-bmp")	||
		($_FILES['txt_file']['type'] == "image/x-xbitmap")	||
		($_FILES['txt_file']['type'] == "image/pjpeg")
	       )
	{
		if (copy ($_FILES['txt_file']['tmp_name'], $destination_file))
		{
			echo ("Copy Failure");
		}
		else
		{
			echo "<p>";
			echo "Image uploaded successfully.";
			echo "</p>";
		}
	}
	else
	{
		echo "Invaild filetype.  Please upload an image";
	}

}else if(isset($_POST['start_upload']) && $_POST['txt_file']['name'] == ""){
echo"
Please enter a file name.
";
};

?>

<html>
   <head>
       <script type="text/javascript">
           window.onload = function() {
               document.getElementById("progress").style.visibility = "hidden";
               document.getElementById("prog_text").style.visibility = "hidden";
           }
           
           
       </script>
       
   </head>
   <body>
   	<?php
	$yid = $_POST['year'];
	?>
       <form name="imageUpload" method="post" action="<?php print $_SERVER["PHP_SELF"]; ?>" enctype="multipart/form-data">
           Please choose a file: <input name="txt_file" type="file" size="35" />
		   <input name="year" type="hidden" value="<?php echo $yid;?>">
           <input type="submit" name="start_upload" value="Upload File"/>
       </form>
       
       <!-- Link to progress file: see http://www.ajaxload.info/ for animated gifs -->
       <img id="progress" src="http://www.your.site/images/progress.gif" />
       <p id="prog_text" style="display:inline;"> Upload Started!</p>
       
   </body>
<html>