My code:
//return > 0 is ok!
function _fileinput($name) {
var_dump($name);
$input['arquivo'] = $_FILES["$name"]["name"];
$input['arquivo'] = strtolower(str_replace("h","",$input['arquivo']));
$input['mimetype'] = $_FILES["$name"]["type"];
$input['temp'] = $_FILES["$name"]["tmp_name"];
$input['mimetypes'] = array("image/jpeg", "image/png");
$input['extencoes'] = array(".jpg", ".jpeg", ".png");
$input['extencao'] = strtolower(end(explode(".",$input['arquivo'])));
$input['mimetype'] = strtolower($input['mimetype']);
$input['novo'] = "[fi]"."[".date('Y-m')."]"."[".strtolower($name)."]"."[".rand(1000,9999)."]".".".$input['extencao'];
var_dump($input);
$x = 0;
if ((array_search($input['extencao'], $input['extencoes']) !== FALSE) AND (array_search(mimetype, $input['mimetypes']) !== FALSE)) {
$x++;
}
else {
$x = 0;
}
var_dump($x);
list($largura, $altura) = getimagesize($input['temp']);
if ($largura == "" || $altura == "") {
$x = 0;
}
else {
$x++;
}
var_dump($x);
if ($x == 2) {
return $input['novo'];
}
else {
return 0;
}
var_dump($x);
}
Paste Version:
How to use:
$fileinput = _fileinput("foto");
if ($fileinput > 0) {
echo $fileinput; //nome para o arquivo
}
else {
echo "deny upload!";
}
Problem:
Does not return the new name for the file, the function in pastebin does not work, why?
Code References: