User User name Password  
   
Monday 6.1.2025 / 21:17
Search AfterDawn Forums:        In English   Suomeksi   På svenska
afterdawn.com > forums > general discussion > all other topics > php / html upload script help
Show topics
 
Forums
Forums
PHP / HTML Upload script help
  Jump to:
 
Posted Message
AfterDawn Addict

3 product reviews
_
19. February 2011 @ 04:34 _ Link to this message    Send private message to this user   
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    Send private message to this user   
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
 

Digital video: AfterDawn.com | AfterDawn Forums
Music: MP3Lizard.com
Gaming: Blasteroids.com | Blasteroids Forums | Compare game prices
Software: Software downloads
Blogs: User profile pages
RSS feeds: AfterDawn.com News | Software updates | AfterDawn Forums
International: AfterDawn in Finnish | AfterDawn in Swedish | AfterDawn in Norwegian | download.fi
Navigate: Search | Site map
About us: About AfterDawn Ltd | Advertise on our sites | Rules, Restrictions, Legal disclaimer & Privacy policy
Contact us: Send feedback | Contact our media sales team
 
  © 1999-2025 by AfterDawn Ltd.

  IDG TechNetwork