afterdawn.com > forums > general discussion > all other topics > php / html upload script help
PHP / HTML Upload script help
AfterDawn Addict
3 product reviews
19. February 2011 @ 04:34
Link to this message
Hi All,
Hoping someone can help, Ive setup my own Ubuntu server mainey for sharing files for the family. I have setup a apache2 webserver, installed PHP etc and created a index.html web front end for it.
The problem is that I have the following error with my upload.php script for file uploads.
Originally posted by error:
Notice: Undefined index: userfile in /var/www/upload.php on line 5 The file install_flash_player.exe has been uploaded
The file uploads still works, so im sure its not a permissions errors and has to be something with the code.
Also, could anyway help me sort it so that after the php script has uploaded the file the page returns to index.html
This is the relevent part of the index.html file
Originally posted by from index.html:
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000000000000000" />
Select File To Send To The TARDIS:
<input name="uploaded" type="file" />
<input type="submit" value="Send to TARDIS" />
</form>
This is my whole upload.php file
Originally posted by from index.php:
<?php
$target = "/var/www/upload/";
$filename = $target.basename($_FILES['uploaded']['name']);
$type = $_FILES['uploaded']['type'];
$size = $_FILES['userfile']['size'];
$ok=1;
//This is our size condition
if ($size > 100000000000000000000000) {
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($type =="text/php") {
echo "No PHP 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 due to OK being Zero";
}
//If everything is ok we try to upload it
else {
if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $filename)) {
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else {
echo "Its seems like we have experienced an anomaly in Time and Space, there was a problem uploading your file.";
}
}
?>
Thanks
Mike
To get instant assistance with Flashing / JTAG / Homebrew from experts for free!
click me (Im not one of the said experts BTW)
Make poverty history, cheaper drugs NOW!
This message has been edited since posting. Last time this message was edited on 19. February 2011 @ 04:39
AfterDawn Addict
3 product reviews
19. February 2011 @ 07:16
Link to this message
Its OK, I fixed it by changing
Originally posted by index.php:
$size = $_FILES['userfile']['size'];
to
Originally posted by index.php:
$size = $_FILES['uploaded']['size'];
To get instant assistance with Flashing / JTAG / Homebrew from experts for free!
click me (Im not one of the said experts BTW)
Make poverty history, cheaper drugs NOW!
afterdawn.com > forums > general discussion > all other topics > php / html upload script help