The cause is to see a simple PHP Upload Script: http://www.nowamagic.net/librarys/veda/detail/1384
I reconstructed it, mainly by replacing the foreach loop with an anonymous function, using the new features of the closure, which also improves the performance. It should be noted that the closure is not completely equivalent to the anonymous function. The closure is implemented through the anonymous function, which is related to the use of the use keyword.
After all, with the addition of many new PHP features, our programmers must keep pace with the times to constantly optimize code and restructure themselves.
The following is the PHP part after reconstruction:
$ IMG = $ _ FILES ['img ']; if ($ IMG) {// file storage directory, same as the PHP File $ dir = dirname (_ file __); array_walk ($ IMG ['tmp _ name'], function ($ value) use ($ Dir, $ IMG) {// ensure that $ IMG ['tmp _ name'] corresponds to $ filename = $ IMG ['name'] [array_search ($ Value, $ IMG ['tmp _ name'])]; // sets the upload path $ savepath = "$ dir \ $ FILENAME"; // upload, and returns the Status $ state = move_uploaded_file ($ value, $ savepath); // If the upload is successful, preview if ($ state) {echo " & nbsp ;";}});}