Hi,
I have modified your code and managed to get it working for you:
HTML Code:
<html>
<head>
</head>
<body>
<form method="post" action="upload.php" enctype="multipart/form-data"/>
<input type='hidden' name='MAX_FILE_SIZE' value='500000' />
<input type="hidden" name="FILE_FORMAT" value="mp4" />
Choose file to upload:<input type="file" name="upload" size='20' />
<input type="submit" name="submit" value="Upload" />
</form>
PHP Code:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
if(isset($_POST['submit'])) {
if(!empty($_FILES['upload']) && ($_FILES['upload']['error'] == 0)) {
$name = $_FILES['upload']['name'];
$target_path = "upload/"; //PUT IN THE PATH WHERE YOU WANT THE UPLOADED FILE TO GO.
$target_path = $target_path . basename( $_FILES['upload']['name']);
if(move_uploaded_file($_FILES['upload']['tmp_name'], $target_path)) { //Move files to your target directory from the tmp directory
echo "The file <strong>". basename( $_FILES['upload']['name']). "</strong> has been uploaded";
} else { //Failure
$msg = "There was an error uploading the file ". basename( $_FILES['upload']['name']). ", please try again!";
}
} else {
echo 'No file was uploaded.';
}
}
?>
HTML Code:
</body>
</html>
This code is by no means secure and still needs more work but I'll leave that up to you.
Bookmarks