Insert upload values into an array with another name?

0

My problem is as follows, I have a form where the user uploads, so that's fine, but I'd like him to insert it with another name, but if so, it inserts blank into the database.

$files=$rand."_".$_FILES['upload']['name'];
$array=implode(",", $files);
echo "<script>alert('Array: ".$array."')</script>";

With the code above, it sends the field $array empty but if I make $files=$_FILES['upload']['name']; it sends right.

    
asked by anonymous 13.12.2017 / 17:30

1 answer

0

Dear friend, if I understand your intention, I recommend you use the pre-defined indexes of the $_FILES of PHP directly.

You are not returning values because you are using implode delimiting by "," but $_FILES returns an array of positions as follows:

[file] => Array
    (
        [name] => MyFile.jpg
        [type] => image/jpeg
        [tmp_name] => /tmp/php/php6hst32
        [error] => UPLOAD_ERR_OK
        [size] => 13
    );

So you do not return a value according to your code, why you did not enter an index of the array to work with and do not have "," to delimit.

    
14.12.2017 / 14:08