- Joined
- Mar 4, 2009
- Messages
- 165
- Reaction score
- 5
Hello
I have coded a upload page in php but it is in 2 pages and i want it 2 be in one page il include my coding.
So if anyone could code that into one page and also fix it so it actually shows the name of the file.
If so TY.
I have coded a upload page in php but it is in 2 pages and i want it 2 be in one page il include my coding.
PHP:
<html>
<head>
<title>Test</title>
</head>
<body>
<form enctype="multipart/form-data" action="<?=$PHP_SELF?>" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
</body>
</html>
PHP:
<?php
$target = "images/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 1000000)
{
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.";
}
}
?>
If so TY.

