THIS TUTORIAL WILL LEAD YOU THROUGH IN FILE UPLOADING AND SAVING FILE FROM THE OPTION SELECTED
NOW CREATE YOU WILL CREATE TWO PAGE
1. Upload.php - where you will upload the file
2. Upload2.php - Where the php code will be executed
NOW COPY THIS AND PASTE IN THE upload.php
THEN SAVE TO YOUR CPANEL AND CREATE ANOTHER FILE upload2.php AND PASTE THIS....BEFORE THAT CREATE A FOLDER WHERE THE FILES WILL BE SAVED
1. Uploads and inside uploads create java_games, java_apps, symbian_apps, symbian_games, pc, themes, pictures, video, musics, zip
NOW COPY THIS INTO THE upload2.php
THEN UPLOAD TO YOUR CPANEL ENJOY!!!
NOW CREATE YOU WILL CREATE TWO PAGE
1. Upload.php - where you will upload the file
2. Upload2.php - Where the php code will be executed
NOW COPY THIS AND PASTE IN THE upload.php
Code:
<form enctype="multipart/form-data" method="post" action="upload2.php"> <label for="file"><strong>File to Upload:</strong></label> <br /> <input id="file" type="file" name="file" /><br /> <br /> <strong>File Category (please select correctly other wise may not be uploaded)<br /> </strong> <select name="option"> <option selected="selected"> Java Games </option> <option> Java Applications </option> <option> Symbian Applications </option> <option> Symbian Games </option> <option> Mobile Themes </option> <option> PC Softwares </option> <option> Musics & Ringtones </option> <option> Zip files, site scripts, prov files and others </option> </select> <br /> <input name="Upload" type="submit" class="style1" value="Upload" /> </form>
1. Uploads and inside uploads create java_games, java_apps, symbian_apps, symbian_games, pc, themes, pictures, video, musics, zip
NOW COPY THIS INTO THE upload2.php
Code:
<?php //this script originated from 2netlodge, please don't remove //assigning directories to variable $jgames = 'uploads/java_games'; $japps = 'uploads/java_apps'; $sapps = 'uploads/symbian_apps'; $sgames = 'uploads/symbian_games'; $pc = 'uploads/pc'; $themes = 'uploads/themes'; $pictures = 'uploads/pictures'; $video = 'uploads/video'; $music = 'uploads/musics'; $zip = 'uploads/zip'; //checking file size before upload if(($_FILES['file']['size']<2000000000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "<div class='me'><div id='even'><center><b>File Successfully Uploaded!</b></center> <div class='rmenu'><b>FILE DETAILS: </b></div> <hr><b>File Name:</b> " . $_FILES["file"]["name"] . "</hr>"; echo "<hr><b>File Type:</b> " . $_FILES["file"]["type"] . "</hr>"; echo "<hr><b>Size: </b>" . ($_FILES["file"]["size"] / 1000) . " Kb</hr>"; echo "<hr><b>Comment: </b>" . $_POST['comment'] . "</hr>"; echo "<hr><b>File Category:</b> " . $_POST['option'] . "</hr><br/>"; } //moving uploaded file to folder depending on the chosen option in upload.php if($_POST["option"]=="Java Games") { move_uploaded_file($_FILES["file"]["tmp_name"], "$jgames" . $_FILES["file"]["name"]); } elseif($_POST["option"]=="Java Applications") { move_uploaded_file($_FILES["file"]["tmp_name"], "$japps" . $_FILES["file"]["name"]); } elseif($_POST["option"]=="Symbian Applications") { move_uploaded_file($_FILES["file"]["tmp_name"], "$sapps" . $_FILES["file"]["name"]); } elseif($_POST["option"]=="Symbian Games") { move_uploaded_file($_FILES["file"]["tmp_name"], "$sgames" . $_FILES["file"]["name"]); } elseif($_POST["option"]=="Mobile Themes") { move_uploaded_file($_FILES["file"]["tmp_name"], "$themes" . $_FILES["file"]["name"]); } elseif($_POST["option"]=="PC Softwares") { move_uploaded_file($_FILES["file"]["tmp_name"], "$pc" . $_FILES["file"]["name"]); } elseif($_POST["option"]=="Musics & Ringtones") { move_uploaded_file($_FILES["file"]["tmp_name"], "$music" . $_FILES["file"]["name"]); } elseif($_POST["option"]=="Zip files, site scripts, prov files and others") { move_uploaded_file($_FILES["file"]["tmp_name"], "$zip" . $_FILES["file"]["name"]); } //if no category not selected else { echo "Sorry no category supports the file type"; } } else echo 'Error Uploading file, try again, check your file size</div></div>'; ?>
Comment