upload php check file extension alowed

  • HOME  • tutorials  • photos   • free grafics design    • questions and answers  • distance calculator  • maps
   



CATEGORIES
EXCEL TUTORIAL
SQL TUTORIAL
WEB INFORMATION
WINDOWS
JAVASCRIPT SCRIPTS
COMPUTER SECURITY
GRAFIC DESIGN
HTML
PHP
CSS STYLE
ATLAS OF THE WORLD
DEVELOPER
PHOTOSHOP
MAGAZINE
TOP LISTS
LATEST ARTICLES
md5 hash generator online tools windows linux c php
remove duplicates in html lines online javascript
documentgetelementbyid()innerhtml javascript set example
how to block processes from starting and running in windows xp
list of us american presidents with pictures
ucwords javascript convert online tool
hex to rgb converter javascript for colors online
letter-spacing css property for html pages
sql inject protection without complicated class php script and tutorial
how to insert decimal values into a sql table row
  home   PHP » UPLOAD PHP CHECK FILE EXTENSION ALOWED
google ads
 
 
 

UPLOAD PHP CHECK FILE EXTENSION ALOWED


Views: 165

STEP 2

Next step is to define the strings for the file extension allowed to be uploaded. Only this extension will be able to move on your server.

For this part you must to create a php page named upload.php in which you have to copy the following lines at the beginning of code .


This part of code validate file extensions to be uploaded via form


//=======================

$extensions = array('.png', '.gif', '.jpg', '.jpeg','.PNG', '.GIF', '.JPG', '.JPEG');
$valid_extensions = '.png , .gif, .jpg, .jpeg';
$extension = strrchr($_FILES['userfile']['name'], '.');

//=======================

You can change alowed extension with your own.




Next step:
copy this code below :


//================

if (!in_array($extension, $extensions))
{
echo'<center>wrong files format , alowed only <strong>"'.$valid_extensions.'"</strong></center>';


//=========================




Note!

$extensions = array('.png', '.gif', '.jpg', '.jpeg','.PNG', '.GIF', '.JPG', '.JPEG');  
we write lower and UPPER leters because some servers do not make the difference ( sensitive case ) 
 


The error message for extension validation will be :

 

wrong files format , alowed only ".png , .gif, .jpg, .jpeg"

!!
You can change the text for this error message but not the part
"'.$valid_extensions.'" ';
 


»
CREATE HTML ( PHP ) FORM
» STEP 2 : VALIDATION PHP : CHECK FILE EXTENSION IF IS  ALOWED / NOT ALLOWED  TO BE UPLOADED
» STEP 3 : VALIDATION PHP : CHECK IF A FILE WITH THE SAME NAME EXIST ON SERVER
» STEP 4 : VALIDATION PHP : CHECK THE FILE MAXIMUM SIZE
» STEP 5 : MOVE UPLOAD FILE IN UPLOAD DIRECTORY ON SERVER



Articles related to UPLOAD PHP CHECK FILE EXTENSION ALOWED
Zero result!

Tags:php upload extension validation,validate extension upload php script,




Leave a comment

Your name *
Your comment *
   Anti Spam code *

There are no comments on this article...Page not found!



the latest articles:
• MD5 hash generator Online tools Windows Linux C Php
• Remove duplicates in html lines online javascript
• documentgetElementById()innerHTML javascript set Example
• How to block processes from starting and running in Windows XP
• List of us american presidents with pictures
• Ucwords javascript convert online tool
• Hex to rgb converter javascript for colors online
• Letter-spacing CSS property for html pages
• SQL Inject protection without complicated class php script and tutorial
• How to insert decimal values into a SQL table row
what is the height of statue of liberty
hollywood movies
map from faisalabad to hasilpur pakistan
driving distance between tanga and bagamoyo
how to abbreviate million dollars
how long do butterflies live in captivity

 

eXTReMe Tracker