upload php check the file name duplicat

  • 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 THE FILE NAME DUPLICAT
google ads
 
 
 

UPLOAD PHP CHECK THE FILE NAME DUPLICAT


Views: 78
STEP 3
CHECK THE DUPLICAT NAME OF FILES ON YOUR SERVER


If we don't do this validation on upload script we will have a unpleasant situation . A file with the same name will be rewritten into the upload folder with the new one. To avoid such situations we have to do the following validation:



First we have to replace the empty space from name of files in upload.php  
 
//==================

$file_name = $_FILES['userfile']['name'];
$file_name = str_replace(' ', '_', $file_name);

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

 

Then we will check the existence of a file with the same name:
 


//==================
if (file_exists('upload/' .$file_name))
{
echo'The file <strong>"'.$_FILES['userfile']['name'].'"</strong>already exist to our server<br>You have to rename the file in your pc!';
//===================



Also we can adding to the name of file a character or something to differentiate it from the existing duplicate file .
 

//===============
if (file_exists('upload/' .$file_name))
{
$file_name = $file_name.'something_here';
}
//===============



NOTE:
Replacing empty spaces with " _  " . can be necessary when you linking to a uploaded file. The empty spaces can generate  big problems ...

you can use also  "-" 


 
» 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 THE FILE NAME DUPLICAT
Zero result!

Tags:upload duplicate files in php,




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