Login

Member statsTotal: 186Latest: MiguelGuests online: 5Members online: 0
EmailLogin here

Location
ForumPHP Tutorials • Simple Upload Form

Access: Member
Total posts: 17

Status: Offline
Simple Upload Form Quote 


Here is the script.. [name this upload.php (or w/e)

PHP Code:
<?php
$target
= "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;

//This is our size condition
if ($uploaded_size > 350000000)
{
echo
"Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if ($uploaded_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";
}

//If everything is ok we try to upload it
else
{
if(
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo
"The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo
"Sorry, there was a problem uploading your file.";
}
}
?>


Then what you wanna do is.. add this script to a page and change the path to the script above...

ALSO-- if you would like to upload files of bigger size change the number found here

PHP Code:

if ($uploaded_size > 350000000)


Code:
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input name="uploaded" type="file" size="30">
<br>
<input type=submit value="Upload">
</form>

to change the size of the text area things mess with the numbers inside size="" [of course the higher the bigger]
----

If you would like this with the password feature.. go back to PHP Tutorials and look for the post called Simple Upload Form

-Tyler
09:12pm 21st Apr 08
_______________
-Tyler
Post a reply!