PHP code to upload any file

PHP code to upload any file.
For this please follow simple instructions below:

  • Create a directory named upload : This is the directory/folder where file is uploading.
  • If you are using Linux/Ubuntu, please give write permission to the upload directory/folder after creating it.
  • This code supported in most of the browsers.
  • Just copy the below code and paste in a file, and run. (Note don’t forget to create folder)

HTML form forĀ uploading file

[sourcecode]




Simple file upload in php



[/sourcecode]

Some CSS to make it beautifull, which should be places in the head section of htmlpage.

[sourcecode]

.main
{
width:100%;
height: auto;
background-color: #CCCCCC;
}
.label {
font-size: 22px;
margin-left: 300px;
}
.input-box {
margin-left: 300px;
margin-top: 20px;
}
.button-box {
margin-left: 300px;
margin-top: 20px;
}
.footer {
background-color: #363636;
clear: both;
color: #ffffff;
font-size: 30px;
margin-bottom: 0;
padding: 22px;
margin-top: 380px
}
.header
{
background-color: #363636;
color: #ffffff;
text-align: center;
}
.saperator
{
height: 50px;
}

[/sourcecode]

 

Now the server code/php script to upload the file

You can use the complete code in one file, you can copy and paste the below code, and run it.

  • Tangle Skills

    Nice Post