The situation:
I have a client who lives far away from me. He's wanting to send me videos. I don't want to confuse him with an upload host.
The problem:
The files are too big, some are 100MB. Here's the error:
Notice: Undefined index: uploadedfile in /home/content/v/i/r/vir/html/upload/index.php on line 21
Notice: Undefined index: uploadedfile in /home/content/v/i/r/vir/html/upload/index.php on line 35
The page does work when you upload an image (~1-3MB). So I'm fairly sure it's the file's size causing this problem. It breaks with an 11MB file and above.
The code I'm using (index.php):
PHP Code:
<?php
ini_set("upload_max_filesize", "204857600");
ini_set("post_max_size", "204857600");
ini_set("max_execution_time", "1200");
set_time_limit(1200);
error_reporting(E_ALL);
?>
<form enctype="multipart/form-data" action="index.php?set=upload&do=up" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="204857600" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
</td></tr><tr><td align="center">
<br />
<input type="submit" value="Upload File" />
</form>
<?php
if ($_GET['do'] == 'up') {
$target_name = basename( $_FILES['uploadedfile']['name']);
$target_path = "";
$ext = end(explode(".",$target_name));
if ($ext == "php") die('php... lol');
$target_path = "" . $target_path . "" . $target_name . "";
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);
echo $target_path . " was successfully uploaded.";
}
echo "<br /><br /><br />Here is a list of the files uploaded:<br />";
if ($handle = opendir('/home/content/v/i/r/vir/html/upload/')) {
echo "Files:<br />";
$files = array();
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if ($file == ".") continue;
if ($file == "..") continue;
if ($file == "index.php") continue;
substr_count($file,".") ? $file = $file : $file .= "/";
$files[$file] = $file;
}
sort($files, SORT_LOCALE_STRING);
foreach ($files as $f) {
echo "<a href=\"$f\">$f</a><br />";
}
closedir($handle);
}
?>
Bookmarks