jquery.repeater
jquery.repeater copied to clipboard
File Uploading
How can I use this to upload file via my server via php,I cannot find the variable names
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 .
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.
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)
Just use new FormData (<FormRepater>)
for file upload