To view this, you need to install the Flash Player 7. Please go to here and download it.

PHP, upload files

1 ) HTML page
<form enctype="multipart/form-data" action="thankyou.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>

  • must have enctype=”multipart/form-data”
  • create “upload” folder inside “form” folder, pictures and files uploaded will be posted there.

2 ) ThankYou page

<?php

$target = “upload/”;

$target = $target . basename( $_FILES['uploaded']['name']) ;

$ok=1;

//This is our size condition

if ($uploaded_size > 350000)

{

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.”;

}

}

?>

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • email
  • LinkedIn
  • MSN Reporter
  • StumbleUpon
  • Twitter
  • Yahoo! Buzz

Related posts:

  1. Adobe cs4 preference keeps reseting every time i restart – troubleshoot
  2. CSS styling input type=”radio”

Tags: ,

This entry was posted on Saturday, March 7th, 2009 at 8:12 pm and is filed under PHP .

Leave a Reply

Name (required)

Mail (will not be published) (required)

Website

Categories