Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown argument on a function on github

I found a good function on github for uploading images using php, but I do not know one of its arguments.

upload_image($_FILES,'file',250,'city',500,'../../uploaded/',1048576);

Function on Github

  1. What is 'file' in this function?
  2. Is this a trusted function to use in my website?

1 Answers

Considering the lines:

$file[$fileIndex]['tmp_name']
$file[$fileIndex]['error']
$file[$fileIndex]['name']
$file[$fileIndex]['type']
$file[$fileIndex]['size']

$file is a three-dimensional array, composed of arrays of name, tmp_name, type, size, error.
It is the kind of array you see when uploading files in PHP.

It calls move-uploaded-file, which moves an uploaded file to a new location.

This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism).
If the file is valid, it will be moved to the filename given by destination.

like image 170
VonC Avatar answered Dec 17 '25 06:12

VonC