首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >uploadifive -上载时更改文件名

uploadifive -上载时更改文件名
EN

Stack Overflow用户
提问于 2012-10-17 04:05:47
回答 2查看 950关注 0票数 0

我正在使用uploadifive上传图像-但是我想将图像的名称更改为"newimage“我不确定在哪里或如何使用所提供的内容-这是我需要部署的最后一个修改。

EN

回答 2

Stack Overflow用户

发布于 2012-10-17 04:24:19

您将需要在处理上传的PHP脚本中进行名称更改(我假设您使用PHP,因为这是uplidfy的标准)。这可能有点棘手,因为您必须将传入的文件名与其扩展名分开。这应该足以让您入门了。

代码语言:javascript
复制
    $theFile = $_FILES['file_upl']['name'];
    $tempFile = $_FILES['file_upl']['tmp_name'];
    $newName = "newname";
    $saveDir = $_SERVER['DOCUMENT_ROOT']."/images/";

    //Function returns the extension from the '.' on
    function get_ext($from_file) { 
        $ext = strtolower(strrchr($from_file,'.'));
        return $ext;
    }

    //This will rename the file to $newname + the extension
    $theFile = $newname.get_ext($theFile);

//Save the file
    move_uploaded_file($tempFile,$saveDir.$theFile);
票数 2
EN

Stack Overflow用户

发布于 2012-10-17 04:20:16

代码语言:javascript
复制
$file = 'uploaded_img.jpg';
$remote_file = 'Saved.txt';

ftp_put($conn_id, $remote_file, $file, FTP_ASCII)

只需更改远程文件的名称

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12922607

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档