本文介绍了如何使用新文件名制作上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好。我有一个问题,所以我想在用户添加新图片时做一些事情,然后他的名字会变成一串唯一的数字。通过编写我想在服务器上写的代码说(用户上传photo.jpg并在服务器上写入),现在我想这样做。 (用户上传image.jpg,服务器重命名为102399_2.jpg(类似的东西)并将其保存在目录和数据库中)。 使用此代码我使用 $ target_dir = photos /; $ target_file = $ target_dir 。 basename($ _ FILES [ fileToUpload] [ name]); $ uploadOk = 1 ; $ imageFileType = pathinfo($ target_file,PATHINFO_EXTENSION); if (move_uploaded_file($ _ FILES [ fileToUpload ] [ tmp_name],$ target_file)) 我尝试过: 随着变化 $ target_file 解决方案 target_dir 。基名( Hello. I have a problem and so I want to do something when the user adds a new picture, then his name will change to a string of unique numbers. By writing code I wanted to write on the server say (the user uploads a photo.jpg and it writes on the server) and now I would like to do so. (The user uploads the image.jpg, the server is renamed to 102399_2.jpg (something like that) and saves it in the directory and in the database). With this code I used$target_dir = "photos/";$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);$uploadOk = 1;$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file))What I have tried:With change $target_file 解决方案 这篇关于如何使用新文件名制作上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 13:18