Advertisement
momca96

image upload script

Jun 23rd, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.97 KB | None | 0 0
  1. <br><br><br><br><br><br><br><br><br><br><br><br><center><div style="width:950px;height:auto;-webkit-border-radius: 20px;-moz-border-radius: 20px;border-radius: 20px;border:1px solid #FF0000;background:rgba(0,0,0,0.6);">
  2. <?php
  3.  
  4. ///////////////////////////////////  OPTIONS  ///////////////////////////////////////////
  5.  
  6.  
  7. $siteurl = "domain.com/folder"; // Your Domain or subdomain (example domain.com or domain.com/folder)
  8.  
  9.  
  10. $sitename = "Image Upload";  // Site name
  11.  
  12.  
  13. $siteslogan = "Slogan";  // Your slogan
  14.  
  15.  
  16. $folder = "images"; // Folder for uploaded images (folder chmod 777)
  17.  
  18.  
  19. $maxsizekb = 4096; // Maximum allowed size of image
  20.  
  21.  
  22. $filetype = array("jpeg", "jpg", "gif", "bmp", "png"); // Allowed types of images
  23.  
  24.  
  25. ///////////////////////////////////////////////////////////////////////////////////////
  26.  
  27.  
  28.  
  29.  
  30.     print("<title>" . $sitename . " - " . $siteslogan . "</title>\n");
  31.     print("<body background=\"pg.jpg\" vlink=\"white\" alink=\"white\" link=\"white\" text=\"white\">\n");
  32.     print("<center>\n");
  33.     print("<h1>" . $sitename . "</h1>\n");
  34.     print("Upload image (max " . $maxsizekb . " KB)<br>\n");
  35.     print("<p>\n");
  36.     print("<form enctype=\"multipart/form-data\" action=\"\" method=\"post\">\n");
  37.  
  38.  
  39.     print("<input name=\"file\" type=\"file\" size=\"60\">\n");
  40.     print("<br><br>\n");
  41.     print("<input type=\"submit\" name=\"upload\" value=\"   Upload   \">\n");
  42.     print("</form>");
  43.  
  44.  
  45.  
  46.  
  47. $maxbyte = $maxsizekb * 4096;
  48.  
  49.  
  50. if(isset($_POST["upload"])) {
  51.     $temp = explode(".", $_FILES['file']['name']);
  52.     $tip = array_pop($temp);
  53.     if($_FILES['file']['size'] > $maxbyte) {
  54.     print("<hr>The file has reached the maximum allowable size!<br>Maximum size: <b>" . $maxsizekb . "KB</b>\n");
  55.     }
  56.     else if(!in_array($tip, $filetype)) {
  57.     print("<hr>That type of image is not allowed!<br>Allowed types: <b>" . implode(", ", $filetype) . "</b>\n");
  58.     }
  59.     else {
  60.     $newplace = $folder . "/" . time() . ".jpg";
  61.     $n = 2;
  62.     if(move_uploaded_file($_FILES['file']['tmp_name'], $newplace)) {
  63.     print("<hr><h2>Successful upload!</h2><br><br>");
  64.     print("Image name: " . time() . ".jpg<br>\n");
  65.     print("Image size: " . $_FILES['file']['size'] . "<br><br>\n");
  66.     print("Direct link: <input type=text name=1 class=code onClick='this.select()' size=50 value='http://" . $siteurl . "/" . $newplace . "'><br><br>\n");
  67.     print("HTML code: <input type=text name=2 class=code onClick='this.select()' size=50 value='<a href=http://" . $siteurl . "/" . $newplace . "><img src=http://" . $siteurl . "/" . $newplace . "></a>'><br><br>\n");
  68.     print("Forum code: <input type=text name=2 class=code onClick='this.select()' size=50 value='[url=http://" . $siteurl . "/" . $newplace . "][img]http://" . $siteurl . "/" . $newplace . "][/img][/url]'><br><br>\n");
  69.     print("<br><img src=" . $newplace . " width=50% height=50%><br><br><br>\n");
  70.     }
  71.     else
  72.     print("<hr><h2>Error!</h2><br><br>\n");
  73.            
  74.     }
  75. }
  76.  
  77. ?>
  78. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement