PHP upload file code, suitable for beginners only, the code is simple and easy to understand.

time:13-08-09 forum:PHP tools and code
  Uploading file functions from http://www.60ie.net/article/6/442.html
PHP is very important in PHP. It is one of the common functions. For example, we want to upload and download files, or to deal with uploaded pictures, all of which need to be used to PHP uploading technology. A simple upload file code can be done, the following is a simple PHP novice file upload code, only suitable for beginners, the code is simple and easy to understand, of course, PHP upload technology far away, we can find a lot of free PHP uploading files on the Internet, the function is quite perfect, and these only need one One kind of file can be realized, if you are a novice, you can study the code for uploading files:
PHP code

[code].Lt; PHP
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Parameter Description:
$max_file_size: setting uploaded files big Small
$destination_folder: upload file save path
$imageview: whether to generate thumbnails (1 for generation, other is not generated)
$imageviewsize: the proportion of thumbnails (the default is 1/2, the size of 50%)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/ / / / upload file type
$FileTypes=array (
'image/jpg',
'image/jpeg',
'image/png',
>); / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / Ion_folder='upfile/'; / / / / upload file save path
$imageview=1; / / / / / / / / / / / / / / / / / / / / / / / / / / / / thumbnail ratio;
$imageviewsize=1/2; / / / thumbnail ratio;
.Gt;
.Lt; html.gt;
Nt-Type.quot; content=.quot; text/html; charset=gb2312.quot; /.gt;
.Lt; title.gt; title.gt; /title.gt; /title.gt;
.Lt; /head.gt;
.Lt; body.gt;
.Lt; form enctype=.quot; multipart/form-data.quot. T; input type=.quot; submit.quot; name=.quot; submit.quot; value=.quot; start to upload.Quot; /.gt;
.Lt; /form.gt; {] {/ >]) 'files do not exist';
exit;
}
$upfile=$_FILES.#91;'file'.#93;
if ($max_file_size.Lt; $upfile.#91;'size'.#93; > > > > > {} / >) / > echo 'file type is not conformed';
exit;
}
if (! File_exists ($destination_folder)) {
MKDIR ($destination_folder);
} / / / defined uploaded file variable / >; Agesize ($filename);
$pinfo=pathinfo ($upfile.#91;'name'.#93;);
/ / print_r ($pinfo);
$file_type=$pinfo.#91;'extension'.#93; STS ($destination)) {
echo.Quot;.Lt; br /.gt; file already exists, no upload success!.quot;
exit;
> > {/ >} / > {} / > {} O ($destination);
/ / / / / / / / / / >
if (! (@getimagesize ($destination))) {
echo 'prohibit illegal operation';
/ / / / / / > unlink / >} / >};
/ / / / print_r ($image_size);
/ / print_r ($pinfo);
echo 'file has been uploaded successfully, the file name is'.$pinof.#91; basename.#93;..quot;.Lt.
echo'.lt; br /.gt; file size'.filesize ($destination).'bytes';
echo'.lt; br echo; Echo 'picture thumbnail.Lt; br /.gt;
echo.Quot;.Lt; img src='.quot;.$destination..Quot; width=.quot;}; [/code] > >.Gt;
.Lt; /body.gt;
.Lt; /html.gt; [/code]

prev:Install.php simple production next:PHP good verification code
post comment
Notice



approved   Do you remember those "made in Ji'na...   Ji'nan's Daming Lake scenic area is ...   Ji'nan free Scenic Area   What is the living condition of the ...   The family photo played by their par...
rand   A brief introduction to the usage of...   Simple application of PHP function p...   Use the PHP function preg_match_all ...   The method for PHP to output array e...   Basic concept of character coding
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com