0 Members and 1 Guest are viewing this topic.
<?php $uploaded_size = $_FILES['uploaded']['size']; $uploaded_type = $_FILES['uploaded']['type']; $target = "/home/omni/uploads"; $allowed = array('mp4','wmv' ,'avi','flv'); $filename = $_FILES['uploaded']['tmp_name']; $ext = pathinfo($filename, PATHINFO_EXTENSION); $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 209715200) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if (!in_array($ext,$allowed)) { echo "Only Video Files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("home/omni/uploads" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); //echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } ?>
<html><body><form enctype="multipart/form-data" action="upload.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form></body></html>
<html><form name="upload" method="POST" action="upload.php">Title: (limit 50 characters)<br /><input type="text" name="title" maxlength="32" style="width:200px;" /><br /><br />Message: (YouTube limits 1000 characters)<br /><textarea name="message" cols="60" rows="20"></textarea><br /><br />Upload Image: (.mp4, .wmv, .avi, .flv, and less than 200MB in size.)<br /><input type="file" name="image" id="image" style="color:#fff;" /><br /><br /><input type="submit" name="upload" value="Upload" /></form>`</html>
Do you mean make folders on your website or do you mean make a folder on the server
And what do you mean with textfiles?That you upload a video + textfile and that they have to be linked together?
Quote from: stevon8ter on November 25, 2012, 03:03:00 pmAnd what do you mean with textfiles?That you upload a video + textfile and that they have to be linked together?Yeah I was thinking they'd both go in a folder together inside of the uploads directory
<form action="uploader.php" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /> <input type="submit" name="submit" value="Submit" /></form>
<?php$allowedExts = array(/*all allowed exts go here*/);$extension = end(explode(".", $_FILES["file"]["name"]));if (($_FILES["file"]["size"] < 10485760 /* file size*/) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { $random_digit=rand(0000,9999); $pathnew = $random_digit . $_FILES["file"]["name"]; echo "Uploaded file name: " . $pathnew . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";$path=random_digit; if (file_exists("../upload/ /*or whatever the upload dir is*/" . $path . "/" . $pathnew)) { $lol = 0;while ($lol === 0){ $random_digit=rand(0000,9999); $pathnew = $random_digit . $_FILES["file"]["name"];$path = $random_digit;if (file_exists("../upload/ /* again whatever upload dir is*/" . $path . "/" . $pathnew)){$lol = 0;}else{$lol = 1;}} } else { mkdir($path);move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $path . "/" . $pathnew); } } }else { echo "Invalid file"; }?>
<?php$allowedExts = array('mp4','wmv','avi','flv'/*all allowed exts go here*/);$extension = end(explode(".", $_FILES["file"]["name"]));if (($_FILES["file"]["size"] < 10485760 /* file size*/) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { $random_digit=rand(0000,9999); $pathnew = $random_digit . $_FILES["file"]["name"]; echo "Uploaded file name: " . $pathnew . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";$path=random_digit; if (file_exists("/home/omni/uploads" . $path . "/" . $pathnew)) { $lol = 0;while ($lol === 0){ $random_digit=rand(0000,9999); $pathnew = $random_digit . $_FILES["file"]["name"];$path = $random_digit;if (file_exists("/home/omni/uploads" . $path . "/" . $pathnew)){$lol = 0;}else{$lol = 1;}} } else { mkdir($path);move_uploaded_file($_FILES["file"]["tmp_name"], "/home/omni/uploads" . $path . "/" . $pathnew); } } }else { echo "Invalid file"; }?>