Combined with the PHP upload method, do not use the plugin, on the flyer file
Reply content:
Combined with the PHP upload method, do not use the plugin, on the flyer file
I really want to lose a sentence, "You give me to search ah ah Ah!" "It doesn't matter to you ...
But considering the results of the search ... Some of them are wrong ... Mislead You bad ... I'll write you one.
Besides, it's been a day, and no one's blaming the poor. Well... The code is as follows ...
function ($action) {return <<< Upload_form<title>Upload Example-step 1-choose File</title>upload_form;},/* a simple error page ... */' upload_error ' = function ($message) {return <<< UPLOAD _error<title>Upload Example-step 2.1-error occurs when uploading</title>Error
{$message}
upload_error;},/* Simple UPLOAD result page appears before file moved ... */' upload_result_1 ' = function (array $ Info) {return <<< upload_result_1<title>Upload Example-step 2.2-show uploaded File Info</title>Basic File Info
-
Name:
-
{$info [' name ']}
-
Type:
-
{$info [' type ']}
-
Size:
-
{$info [' Size ']}
-
Path:
-
{$info [' Tmp_name ']}
upload_result_1;},/* Simple UPLOAD RESULT page appears after file moved ... */' upload_result_2 ' = function (array $result) {return <<< upload_result_2
Final processing Result
-
from:
-
{$result ["from"]}
-
Move to:
-
{$result [' to ']}
-
Status:
-
{$result [' status ']}
Upload_result_2;} ];/* show the page off ... */echo isset ($html [$name])? $html [$name] ($param): "; return;};/ * Define where uploaded file should stored in ... */define (' Upload_path ', ' UPLOAD ');/* simple-to-judge whether we go t a file or not ... */if (! isset ($_files[' file '))/* * No file ... Time to upload ... */$template (' Upload_form ', $_server[' php_self ');/* Well ... it seems that we had something to D O ... */else {/* Let us rock ... */try {/* make a alias and make sure our file uploaded normally ... */ if (Upload_err_ok = = = ($error = $_files[' file ' [' Error '])) {/* Hooray ... show the result and make a nother alias ... */$template (' upload_result_1 ', ($file = $_files[' file ')); /* This is not the end ... we need to confirm this file ... */$checker = function ($file) {/* You can deny a file if it too large */if ($file [' size '] > 1234); /* You can also deny a file if want it ... */if (! In_array ($file [' Type '], [' Image/jpeg ', ' image/png ']); /* You can even specify the file name ... */if (' Sunyanzi.zip '!== $file [' name ']); /* In a word ... do everything-want here ... */return true; }; /* Initialize the result array ... */$result = [' from ' = = $file [' Tmp_name '], ' To ' = ' $_server[' document_root '. Directory_separator. Upload_path. Directory_separator. $file [' name '], ' status ' = ' Failure ']; /* is the file passed our examination ...? */if (true = = = $checker ($file)) {/* Prepare store path ... */if (! is_dir (Upload_path)) mkdir (Upload_path, 0755, true); /* Move file to the right place and keep its name ... */if (Move_uploaded_file ($file [' tmp_name '), Upload_path. Directory_separator. $file [' name '])/* Change status to Success ... */$result [' St ATUs '] = ' Success '; }/* Show the final result and we have done ... */$template (' upload_result_2 ', $result); /* Something wrong with it ...? */} else {/* Failure ... what happened ... let us find it out! */$error _messages = [ Upload_err_ini_size = ' The uploaded file exceeds the Upload_max_filesize '. ' directive in php.ini. ', upload_err_form_size = ' The uploaded file exceeds the Max_file_size direct '. ' Ive that is specified in the HTML form. ', Upload_err_The PARTIAL = ' The uploaded file is only partially uploaded. ', Upload_err_no_file = ' No file was uploaded. ', Upload_err_no_tmp_dir = ' Mi Ssing a temporary folder. ', Upload_err_cant_write = ' Failed to WRITE the file to disk. ', upload_err_extension = ' A PHP EXTENSION stopped the file UPLOAD. ' ]; /* Throw the error out! */throw new Exception (Isset ($error _messages[$error])? $error _messages[$error]: ' Unknown error '); }/* Something wrong. */} catch (Exception $ex) {/* show it out ... */$template (' Upload_error ', $ex->getmessage ()); }}
Didn't write anything fancy ... The whole process is simple ...
The first is to define all the HTML pages used ... Then define the upload path ... Then there is the part of the upload ...
See where there is not clear can ask again ...
and say ... My $checker
only use for demo ... So the writing is very simple ...
But the fact that open users are free to upload is a dangerous behavior ... If you're sure you want to use ... Be sure to keep it safe ...
Well, that's it.