Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['play-name'])) {
  3. $picture ='uploads/noimage.png';
  4. $formInputName   = 'play-img';                          # This is the name given to the form's file input
  5.     $savePath        = ABSPATH.'/uploads';                              # The folder to save the image
  6.     $saveName        = md5(time()).'-'.user_id();                                   # Without ext
  7.     $allowedExtArray = array('.jpg', '.png', '.gif');   # Set allowed file types
  8.     $imageQuality    = 100;
  9. $uploader = new FileUploader($formInputName, $savePath, $saveName , $allowedExtArray);
  10. if ($uploader->getIsSuccessful()) {
  11. //$uploader -> resizeImage(200, 200, 'crop');
  12. $uploader -> saveImage($uploader->getTargetPath(), $imageQuality);
  13. $thumb  = $uploader->getTargetPath();
  14. $picture  = str_replace(ABSPATH.'/' ,'',$thumb);
  15. }
  16. if(intval($_POST['categ']) > 0) {
  17. $ch = $_POST['categ'];
  18. } else {
  19. $ch = null;
  20. }
  21.  
  22. $db->query("INSERT INTO ".DB_PREFIX."postcats (`cat_name`, `picture`, `cat_desc`) VALUES ('".toDb($_POST['play-name'])."', '".toDb($picture)."' , '".toDb($_POST['play-desc'])."')");
  23. echo '<div class="msg-info">Blog category "'.$_POST['play-name'].'" created</div>';
  24. }
  25.  
  26. ?><div class="row-fluid">
  27. <form id="validate" class="form-horizontal styled" action="<?php echo admin_url('create-pch');?>" enctype="multipart/form-data" method="post">
  28. <fieldset>
  29. <div class="control-group">
  30. <label class="control-label">Category's title</label>
  31. <div class="controls">
  32. <input type="text" name="play-name" class="validate[required] span12" placeholder="<?php echo _lang("The title"); ?>" />                       
  33. </div> 
  34. </div> 
  35.  
  36. <div class="control-group">
  37. <label class="control-label"><?php echo _lang("Description"); ?></label>
  38. <div class="controls">
  39. <textarea rows="5" cols="5" name="play-desc" class="auto span12" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 88px;"></textarea>                
  40. </div> 
  41. </div>
  42. <div class="control-group">
  43. <label class="control-label"><?php echo _lang("Image"); ?></label>
  44. <div class="controls">
  45. <input type="file" id="play-img" name="play-img" class="styled" />
  46. </div> 
  47. </div>
  48. <div class="control-group">
  49. <button class="btn btn-large btn-primary pull-right" type="submit"><?php echo _lang("Create"); ?></button> 
  50. </div> 
  51. </fieldset>                    
  52. </form>
  53. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement