Guest User

Untitled

a guest
Sep 24th, 2011
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.14 KB | None | 0 0
  1. Hi nairalanders, please I have being working on a media site for few months now and I have designed everything that needs to be designed but A♏ having problems with my uploading code its not storing the file size in the database,  I have tried and tried and all what have being doing seem to be taking me away from the right way with my little understanding of php. Here is the code that is giving me headache
  2.  
  3.  
  4. ,
  5. <?php //include("includes/sess.php"); ?>
  6. <?php
  7. $upload="active";
  8. include("includes/mheader.php"); ?>
  9. <?php
  10. if(isset($_POST['Upload'])) {
  11. //////////////////////////////////
  12. //$id=$_POST['id'];
  13. $picture=$_POST['picture'];
  14. $artiste=$_POST['artiste'];
  15. $title=$_POST['title'];
  16. $genre=$_POST['genre'];
  17. $uname=$_POST['uname'];
  18.  
  19.  
  20.  
  21.  
  22. if($title=="")
  23. {
  24. $message="unknown Title";
  25. header("location:upload.php?message=$message");
  26. exit();
  27. }
  28.  
  29. if($genre=="")
  30. {
  31. $message="unknown Type";
  32. header("location:upload.php?message=$message");
  33. exit();
  34. }
  35.  
  36. /*if($nfile=="")
  37. {
  38. $message="file not found";
  39. header("location:upload.php?message=$message");
  40. exit();
  41. }   */
  42.  
  43.  
  44.  
  45. if($uname=="")
  46. {
  47. $message="error you";
  48. header("location:upload.php?message=$message");
  49. exit();
  50. }
  51.  
  52. if($artiste=="")
  53. {
  54. $message="Artiste ?";
  55. header("location:upload.php?message=$message");
  56. exit();
  57. }
  58.  
  59. header("location:upload.php?message=$message");
  60.  
  61. //////////////////////////////////
  62. $size=$_FILES["picture"]["size"];
  63. $file_size1 = $size/1024 ;
  64. $file_size = $file_size1/1000 ;
  65. function UploadOne($fname)
  66. {
  67. $uploaddir = 'music/NaijaMp3_';
  68. if (is_uploaded_file($fname['tmp_name']))
  69. {
  70. $filname = basename($fname['name']);
  71. $uploadfile = $uploaddir . basename($fname['name']);
  72. if (move_uploaded_file ($fname['tmp_name'], $uploadfile))
  73. $res = "File " . $filname . " was successfully uploaded and stored.<br>";
  74. else
  75. $res = "Could not move ".$fname['tmp_name']." to ".$uploadfile."<br>";
  76. }
  77. else
  78. $res = "File ".$fname['name']." failed to upload.";
  79. return ($res);
  80. }
  81. ?>
  82. <?php
  83. if ($_FILES['picture']['name'] != "")
  84. {
  85. $res = UploadOne($_FILES['picture']);
  86. $filname = $_FILES['picture']['name'];
  87. $filname=addslashes($filname);
  88. /////////////////////////////////////////////////////////////
  89. $alt_file_name = "NaijaMp3_" .$filname ;
  90.  
  91. $date_created=date("Y-m-d h:i:A");
  92. include("includes/db_connect.php");
  93. $sql="INSERT INTO upmp3(uname,file_name,alt_file_name,file_size,artiste,title,genre,date_created)
  94. VALUES('$uname','$filname','$alt_file_name','$file_size','$artiste','$title','$genre','$date_created')";
  95. mysql_query($sql) or die (mysql_error());
  96. $message="Upload Sucessful";
  97. /////////////////////////////////////////////////////////////
  98.  
  99. echo ($res);
  100. }
  101. }
  102. ?>
  103.  
  104.  
  105.  
  106.  
  107. <div class="main_but">
  108.  
  109. </div>
  110.  
  111.  
  112.  
  113.  
  114.  
  115. </div>
  116.  
  117. <!-- Navigation begins here -->
  118. <!-- Header section ends here --></div>
  119. <div class="login">
  120. </div>
  121. <div id="feature">
  122. <blockquote/>
  123.  <div align="center"><em><strong>UPLOAD FILE </strong></em></div>
  124.  <form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  125.     <p>
  126.     <br />
  127.    
  128.     </p>
  129.  <p>{Note: All * fields are Mandatory} </p>
  130.     <p>
  131.       <label>
  132.       <input name="picture" type="file" id="picture" />
  133.       </label>
  134.     </p>
  135.     <p>File Type
  136.       <label>
  137.       <select name="type" id="type">
  138.         <option value="mp3">mp3</option>
  139.          </select>
  140.       </label>
  141.     </p>
  142.     <p>Artiste*<span class="style1"><sub>(e.g Alashine)</sub></span>
  143.       <label>
  144.       <input name="artiste" type="text" id="artiste" />
  145.       </label>
  146.       Title
  147.        
  148.       <label>
  149.         <input name="title" type="text" id="title" /><span class="style1">
  150.       </label>
  151.       <p>Genre
  152.       <label><input name="genre" type="text" id="genre" />(Genre e.g Hiphop, RnB, Reggae . . .)</span></label>
  153.       <input type='hidden' name='id' value='<?php echo"$id" ?>' id='id'/>
  154.       <input type='hidden' name='uname' value='<?php echo"$uname" ?>' id='uname'/>
  155.       <label></label>
  156.     </p>
  157.  
  158.  
  159.     </p>
  160.     <p>
  161.       <label>
  162.       <input name="Upload" type="submit" id="Upload" value="Upload Mp3" />
  163.       </label>
  164. </p>
  165.   </form>
  166. </div>
  167. </div>
  168. <?php include("includes/footer.php"); ?>
  169. </div>
Advertisement
Add Comment
Please, Sign In to add comment