Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- ,
- <?php //include("includes/sess.php"); ?>
- <?php
- $upload="active";
- include("includes/mheader.php"); ?>
- <?php
- if(isset($_POST['Upload'])) {
- //////////////////////////////////
- //$id=$_POST['id'];
- $picture=$_POST['picture'];
- $artiste=$_POST['artiste'];
- $title=$_POST['title'];
- $genre=$_POST['genre'];
- $uname=$_POST['uname'];
- if($title=="")
- {
- $message="unknown Title";
- header("location:upload.php?message=$message");
- exit();
- }
- if($genre=="")
- {
- $message="unknown Type";
- header("location:upload.php?message=$message");
- exit();
- }
- /*if($nfile=="")
- {
- $message="file not found";
- header("location:upload.php?message=$message");
- exit();
- } */
- if($uname=="")
- {
- $message="error you";
- header("location:upload.php?message=$message");
- exit();
- }
- if($artiste=="")
- {
- $message="Artiste ?";
- header("location:upload.php?message=$message");
- exit();
- }
- header("location:upload.php?message=$message");
- //////////////////////////////////
- $size=$_FILES["picture"]["size"];
- $file_size1 = $size/1024 ;
- $file_size = $file_size1/1000 ;
- function UploadOne($fname)
- {
- $uploaddir = 'music/NaijaMp3_';
- if (is_uploaded_file($fname['tmp_name']))
- {
- $filname = basename($fname['name']);
- $uploadfile = $uploaddir . basename($fname['name']);
- if (move_uploaded_file ($fname['tmp_name'], $uploadfile))
- $res = "File " . $filname . " was successfully uploaded and stored.<br>";
- else
- $res = "Could not move ".$fname['tmp_name']." to ".$uploadfile."<br>";
- }
- else
- $res = "File ".$fname['name']." failed to upload.";
- return ($res);
- }
- ?>
- <?php
- if ($_FILES['picture']['name'] != "")
- {
- $res = UploadOne($_FILES['picture']);
- $filname = $_FILES['picture']['name'];
- $filname=addslashes($filname);
- /////////////////////////////////////////////////////////////
- $alt_file_name = "NaijaMp3_" .$filname ;
- $date_created=date("Y-m-d h:i:A");
- include("includes/db_connect.php");
- $sql="INSERT INTO upmp3(uname,file_name,alt_file_name,file_size,artiste,title,genre,date_created)
- VALUES('$uname','$filname','$alt_file_name','$file_size','$artiste','$title','$genre','$date_created')";
- mysql_query($sql) or die (mysql_error());
- $message="Upload Sucessful";
- /////////////////////////////////////////////////////////////
- echo ($res);
- }
- }
- ?>
- <div class="main_but">
- </div>
- </div>
- <!-- Navigation begins here -->
- <!-- Header section ends here --></div>
- <div class="login">
- </div>
- <div id="feature">
- <blockquote/>
- <div align="center"><em><strong>UPLOAD FILE </strong></em></div>
- <form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
- <p>
- <br />
- </p>
- <p>{Note: All * fields are Mandatory} </p>
- <p>
- <label>
- <input name="picture" type="file" id="picture" />
- </label>
- </p>
- <p>File Type
- <label>
- <select name="type" id="type">
- <option value="mp3">mp3</option>
- </select>
- </label>
- </p>
- <p>Artiste*<span class="style1"><sub>(e.g Alashine)</sub></span>
- <label>
- <input name="artiste" type="text" id="artiste" />
- </label>
- Title
- <label>
- <input name="title" type="text" id="title" /><span class="style1">
- </label>
- <p>Genre
- <label><input name="genre" type="text" id="genre" />(Genre e.g Hiphop, RnB, Reggae . . .)</span></label>
- <input type='hidden' name='id' value='<?php echo"$id" ?>' id='id'/>
- <input type='hidden' name='uname' value='<?php echo"$uname" ?>' id='uname'/>
- <label></label>
- </p>
- </p>
- <p>
- <label>
- <input name="Upload" type="submit" id="Upload" value="Upload Mp3" />
- </label>
- </p>
- </form>
- </div>
- </div>
- <?php include("includes/footer.php"); ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment