jquery.repeater icon indicating copy to clipboard operation
jquery.repeater copied to clipboard

File Uploading

Open Aggreyluts opened this issue 7 years ago • 4 comments

How can I use this to upload file via my server via php,I cannot find the variable names

Aggreyluts avatar Jun 15 '17 19:06 Aggreyluts

if your list name is attachment_file and the input name is file_upload , use this code ` foreach($_FILES['attachment_file'] AS $k => $v){ foreach( $v AS $v2){ $attach_file[$i][$k]=$v2['file_upload']; $i++; } $i=0;

    }

` now use $attach_file as normal $_FILES .

mzrahmani avatar Aug 21 '17 10:08 mzrahmani

I had the same problem, but I have just solved it:

Mi repeater element is this one:

data-repeater-list="questions"

Inside the repeater element I have an input file as this one:

<input type="file" name="qImage_html" >

So in my PHP server side I have this code to get the uploaded files:

$cont=0;
foreach($_FILES['questions'] AS $k => $v){
	foreach( $v AS $v2){
		$attach_file[$cont][$k]=$v2['qImage_html'];
		$cont++;
	}
}

...

for ($i = 0; $i < sizeof($file_ary); $i++) {

	$uploadedFile = null;
	if (isset($file_ary[$i]) && (!file_exists($file_ary[$i]['tmp_name']) || !is_uploaded_file($file_ary[$i]['tmp_name']))) {
		/* NOT FILE UPLOADED */
	} else {
		$uploadedFile = $file_ary[$i];
		/* DO WHATEVER YOU WANT WITH UPLOADED FILE */
	}
	
}

Hope this helps.

asier-laukoa avatar Nov 29 '19 09:11 asier-laukoa

How do you create the array $ file_ary since in the first loop you create the array $ attach_file.

(5) [{…}, {…}, {…}, {…}, {…}] 0: {name: "20111451592-01-FR03-00053793.pdf"} 1: {type: "application/pdf"} 2: {tmp_name: "C:\Users\Juan Carlos\AppData\Local\Temp\php74BC.tmp"} 3: {error: 0} 4: {size: 48005} length: 5 proto: Array(0)

grupoconexo avatar Jun 29 '20 14:06 grupoconexo

Just use new FormData (<FormRepater>) for file upload

mrsnax avatar Dec 04 '22 12:12 mrsnax