slim php framework image upload put database
问题 I am new to slim php framework, I want to upload an image and put the file name in the database via POST , can some one kindly give me some example code. 回答1: Here's the router: $app->post('/', 'uploadFile'); this will point to the function below: function uploadFile () { if (!isset($_FILES['uploads'])) { echo "No files uploaded!!"; return; } $imgs = array(); $files = $_FILES['uploads']; $cnt = count($files['name']); for($i = 0 ; $i < $cnt ; $i++) { if ($files['error'][$i] === 0) { $name =