Manual of PHP

 
 
 

Web map

 
rim   rim
arrowReady frontarrow of Codes PHParrow to Raise Files

 

To raise Files To print E-mail

To raise files to a servant, the only thing that we must do it is to put in a form a field of file as the following ones:

<form action = "" method = "post" enctype = "multipart/form-data">
  <unputt type = "file" yam = "file"/>
  <unputt type = "submit" yam = "submit" values = "to Raise image"/>
</form>

On having sent the form, the navigator sends automatically the file of the field to the temporary folder of the servant, but the problem is once in this folder how to move it to the folder that us one take a fancy.

And here it is where it enters action PHP and the function move_uploaded_file that will move the deep file of the temporary folder to the folder that we say to him and even with the name that we should put him.

<?
$destino = 'uploaded';
move_uploaded_file ($_FILES ['file'] ['tmp_name'], $destino. '/'. $_FILES ['file'] ['yam']);
?>

Where $_FILES ['file'] ['tmp_name] it will identify the temporary file raised to the servant, $destino, the folder in which we want to move it and $_FILES ['file'] ['yam] the original name of the file.

Also also we can know other parameters of the file raised like for example the size, we are going to see an example:

<?
$destino = 'uploaded';
//We read the size of the file
$tamano = $_FILES ['file'] ['size'];
//Comprovamos the size
if ($tamano <500) {
move_uploaded_file ($_FILES ['file'] ['tmp_name'], $destino. '/'. $_FILES ['file'] ['yam']);
}
else I begin "The size is superior to the authorized one";
?>

Also we can know the type of file raised with the following variable: $_FILES ['file'] ['type'];

It notices: For versions previous to 4.0.1 of PHP, instead of the vector $_FILES, we must use $HTTP_POST_FILES.

Article for courteousness of Eloi of St Martin
www.programacionweb.net

 

 
Front
Chapters of the Manual of PHP
Introduction to PHP
Variables
My First Script PHP
Operators in PHP
Structures of Control
Functions in PHP
Code inclusion
Counterfoils (array)
Chains of Characters
Classes
Dates
Entry and Exit
Operations with Files
The language SQL and PHP
Connection with MySQL
Meetings
Forms with PHP
To practise in line
List of practices in line
FAQ
Frequent questions
Codes PHP
List of Codes PHP
Forums
Forums PHP
Other Manuals
Manuals of other languages
 
   
 
 
MySpaceScripts.info - Sitemap - Contact us - Sitemap - Contact us - Sitemap - Contact us

Shower Enclosures , speed test , auto.moto-point.co.uk , Patek Philippe Replika Uhren , Holzhäuser , auto brands , used cars