Upload 2 files and rename them
I have found very usefull to use php rename code of file upload action to rename a filename
but my doubt is if it posible to do with 2 filenames
files config
file1:jpg
file2:jpg
arrayfields
file1,file2
php rename code
but it doesnt work, it assign first name to both files, i think do I have to use two action?
<?php
return "newnamefile1";
?>
but my doubt is if it posible to do with 2 filenames
files config
file1:jpg
file2:jpg
arrayfields
file1,file2
php rename code
<?php
return "newnamefile1.jpg";
return "newnamefile2.jpg";
?>
but it doesnt work, it assign first name to both files, i think do I have to use two action?
I fear in this case this is more complex question because is about to use the latest feature implemented in latest versión 5.08 that allows to rename a file that is uploaded , but so far I have only got with one file
Hi Teldrive,
The $file_name variable holds the clean field name, which means that you can use:
Regards,
Max
The $file_name variable holds the clean field name, which means that you can use:
<?php
return "prefix".$file_name;
Regards,
Max
Hi Max, thanks for reply
the issue is when there is only one file to upload i can set
the issue is when there are 2 files and we want to use a fixed name for each, my question is regarding how can i detect
when file1 or file 2 are uploaded in order to set
the issue is when there is only one file to upload i can set
<?php return "newnamefile1.jpg"; ?>
, we need in our application to know the namefile "newnamefile"
the issue is when there are 2 files and we want to use a fixed name for each, my question is regarding how can i detect
when file1 or file 2 are uploaded in order to set
<?php
if(file1) return "newnamefile1.jpg";
if(file2) return "newnamefile2.jpg";
?>
This is not possible, its a static feature, you can't know which file is being uploaded, only the file name can be used.
Regards,
Max
Regards,
Max
Maybe a new small addition can make this possible, please send me a message using the "contact us" page to try it!
Regards,
Max
Regards,
Max
it works like a charm, thanks Max😀
here is my working code to upload 3 files and rename them to a fixed name(very useful if you setup parameters of a web page)
[attachment=0]Captura.JPG[/attachment]
here is my working code to upload 3 files and rename them to a fixed name(very useful if you setup parameters of a web page)
<?php
global $x;
if(!isset($x)){
$x = 1;
}else{
$x++;
}
switch ($x) {
case 0:
break;
case 1:
return "file1.jpg";
break;
case 2:
return "file2.jpg";
break;
case 3:
return "file3.jpg";
break;
}
?>
[attachment=0]Captura.JPG[/attachment]
This topic is locked and no more replies can be posted.