Location: PHPKode > projects > Trunk.net > bitbucket-upload.php
<?php
ob_start("ob_gzhandler");

require "include/functions.php";
dbconn(false);
stdhead("bitbucket");
?>

<?
//set these variables-----------------------------------------------------------------
$domain = "torrents.idle.ro";      //your domainname
$path = "bitbucket/";   //path to your targetfolder
$path_after_domain = "/bitbucket/";   //path to your targetfolder for use in url
$max_size = 500000;          //maximum filesize
//------------------------------------------------------------------------------------
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>file upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<style type="text/css">
<!--
.style1 {
	font-size: 11px;
	font-weight: bold;
	color: #FF0000;
}
-->
</style>
</head>
<FORM ENCTYPE="multipart/form-data" ACTION="bitbucket-upload.php" METHOD="POST">
      <p class="style1 ">Bit-bucket upload</p>
      <table border=1 cellspacing=0 cellpadding=5>
        <tr>
          <td class=rowhead>Upload file</td>
          <td><INPUT NAME="userfile" TYPE="file" id="userfile">            </td>
        </tr>
        <tr>
          <td colspan=2 align=center><input name="submit" type="submit" id="submit" value="Upload">          </td>
        </tr>
      </table>
</FORM>

<br>
<?

if (!isset($HTTP_POST_FILES['userfile'])) exit;

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
      echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File is too big !</font><br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {

      if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) {
              echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">There already exists a file with this name, please rename your file and try again</font><br>\n"; exit; }

      $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .$HTTP_POST_FILES['userfile']['name']);

      if (!$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Didn't work, please try again</font><br>\n"; exit; } else {
      ?>
<br>
<p>
<font color="#333333" face="Geneva, Arial, Helvetica, sans-serif">Find your file here: <strong><font color="#990000"><a href="http://<? echo $domain; ?>/<? echo $path_after_domain; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>" target="_blank"><br>
http://<? echo $domain; ?>/<? echo $path_after_domain; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?><br>
</a></font></strong><br>
HTML:<br>
<font color="#990000"><strong>&lt;img src=&quot;http://<? echo $domain; ?>/<? echo $path_after_domain; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>&quot;&gt;</strong></font><br>
<br>
BBCode: <font color="#990000"><strong><br>
[img]http://<? echo $domain; ?>/<? echo $path_after_domain; ?><? echo $HTTP_POST_FILES['userfile']['name']; ?>[/img]</strong></font></font></p>
<?
}
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><hr>";
echo "Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";
echo "Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n";
echo "Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n";
echo "</font>";
echo "<br><br><img src=\"http://".$domain."/".$path_after_domain.$HTTP_POST_FILES['userfile']['name']."\">";
} else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">You may only upload file types with the extensions .gif or .jpg !!!</font><br>\n"; exit; }

}

?>


</body>
</html>

<?
stdfoot();
?>
Return current item: Trunk.net