Usually we cannot reassign $ _Files, which means that we cannot pass an automatic super global variable as an argument to a -or-function. But we have alternative solutions.
Pass the file as a parameter
function ImageProcess(array $_File){ $image = $_FILES["file"]["name"]; $uploadedfile = $_FILES['file']['tmp_name'];
A function call with an automatic global variable as an argument.
if ($_SERVER['REQUEST_METHOD'] == "POST") { if(isset($_FILES['file'])){ echo ImageProcess($_FILES['file']); } }
Download Form
<form method="post" action="<?php $_SERVER['PHP_SELF'];?>" enctype="multipart/form-data"> <input type="file" name="file" /> <button type="submit">Update & Save</button> </form>
source share