我想将图像的名称设置为与name =“”字段相同。
这是我在上传图像时设置图像的名称,XXXX所在的位置,这就是我要输出的名称'front',它存储在HTML FILE输入中的name =“front”中:
$custom_name = "[" . "CANON" . "]_" . "XXXXXX";HTML:
<form method="POST" class="admin_image_form" action="" enctype="multipart/form-data"> <div class="input-tag">Front</div> <label class="upload-button"> <input type="file" name="front"> Choose Image </label><br> </form>我已经尝试用' $_FILES['front']['name']替换XXXX但是这只是将上传的文件名设置为' CANON_.png ',然后是图像的原始名称,我希望它是'带有' front '的CANON_front.png '来自html中的name="front"
谢谢你的帮助。
I would like to set the name of the image to be the same as the name="" field.
This is where I set the name of the image when its been uploaded, where the XXXX is, this is where I want to output the name 'front' that is stored in name="front" in the HTML FILE Input:
$custom_name = "[" . "CANON" . "]_" . "XXXXXX";HTML:
<form method="POST" class="admin_image_form" action="" enctype="multipart/form-data"> <div class="input-tag">Front</div> <label class="upload-button"> <input type="file" name="front"> Choose Image </label><br> </form>I have tried replacing the XXXX with '$_FILES['front']['name']' however this just sets the uploaded file name to 'CANON_.png' followed by the original name of the image, I want it to be 'CANON_front.png' with 'front' coming from the name="front" in html
Thanks for any help.
最满意答案
您可以简单地将一个变量分配给FILES数组的名称,然后使用后面的文件名添加连接的下划线,前面是“CANON”。
$file = $_FILES['front']['name']; $new_name = "CANON" . "_" . $file;You can simply assign a variable to the FILES array's name and then tack on a concatenated underscore with the file name after it, that is preceded by "CANON".
$file = $_FILES['front']['name']; $new_name = "CANON" . "_" . $file;更多推荐
'front',XXXX,class,电脑培训,计算机培训,IT培训"/> <meta name="
发布评论