douji8017 2013-12-27 16:35
浏览 172
已采纳

dropzone.js:如何重命名文件?

I want to rename a file uploaded with dropzone.js. I have read the other question of rename file with dropzone, but I don't understand.

I've tried this:

this.on("sending", function(file, xhr, formData) { 
    var abdocument.getElementById("a").value
    var nick = document.getElementById("b").value;
    formData.append("fileName", a+ " - " + b);
    });
  }
};

but then how can I use this "fileName"? I've to use in php function? This is mine:

<?php

$upload_folder = 'uploads';
if (!empty($_FILES)) {
  $temp_file = $_FILES['file']['tmp_name'];
  $target_path = dirname( __FILE__ ) .  '/' . $upload_folder . '/';
  $target_file =  $target_path . $_FILES['file']['name'];


  if( file_exists( $target_path ) ) {
    move_uploaded_file($temp_file, $target_file);
  } else {
    header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
  }
}

?>

or can I rename via javascript?

Thanks to all

  • 写回答

2条回答 默认 最新

  • doushan7997 2013-12-27 18:43
    关注

    Ok, I have to do this:

    $_FILES['file']['name'] = ($_POST["fileName"]);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型