标签云

微信群

扫码加入我们

WeChat QR Code

I want to capture the scans from$_FILES, because there will be always passed an empty scan input name and the varry of other can change, I need to get the $_FILES name's and the number. Do you have any advice how to accomplish that?// Skipping the empty scan, and getting the 0-100 possible$results = preg_grep('/^scan\d{1,2}$/', $_FILES);Generates Array to string conversion errorThe post dump["scan0"]=>array(5) {["name"]=>string(6) "2.jpeg"["type"]=>string(10) "image/jpeg"["tmp_name"]=>string(24) "C:\xampp\tmp\phpD7B4.tmp"["error"]=>int(0)["size"]=>int(24618)}["scan1"]=>array(5) {["name"]=>string(6) "2.jpeg"["type"]=>string(10) "image/jpeg"["tmp_name"]=>string(24) "C:\xampp\tmp\phpD7B5.tmp"["error"]=>int(0)["size"]=>int(24618)}["scan"]=>array(5) {["name"]=>string(0) ""["type"]=>string(0) ""["tmp_name"]=>string(0) ""["error"]=>int(4)["size"]=>int(0)}


What have you tried so far? Have you already tried to use foreach loop for iterating over $_FILES and use preg_match to extract the name and the number of your files?

2019年04月19日34分23秒

Gonna try that, wanted do that after preg_match

2019年04月19日34分23秒

Well need to get the [scan0] like things first.

2019年04月18日34分23秒

You dont need to. Look at the error value on the 'empty' can. The process is to check the error number. if not zero then don't process otherwise do the move_uploaded_file(). The only real thing you need to worry about is that duplicate filenames will overwrite each other.

2019年04月18日34分23秒

Well I do not want to get the $scan['name'], I want to get the key above it, so the scan0 array, that's why I want to get only $_FILES['/^scan\d{1,2}$/'] like

2019年04月18日34分23秒

Answer updated..

2019年04月19日34分23秒

This might be good, but as said I need to get the element name not the name itself.

2019年04月19日34分23秒

array_filter only removes the empty element.. array_keys gets what you actually need.. scan0, scan1..

2019年04月19日34分23秒

Oh, indeed tell me how can I remove also the $_FILES['otherscan'] from the filter

2019年04月18日34分23秒