plugins - How can I create a secure file download in WordPress?

I need you help. I'm currently trying to develop a secure file download in PHP and WordPress. I've already don

I need you help. I'm currently trying to develop a secure file download in PHP and WordPress. I've already done the upload and deletion part but now I need to handle the download - somehow.

The file get's saved inside a deny from all folder in the wp-uploads directory.

Currently I have a table with an entry for each file and one download button at the top. When I now select some rows and click the download button, I'm doing an AJAX request to my backend:

$("#storage-download-btn").click(function() {
  let data = {
    action: "download_from_storage",
    selected_storage_files: getSelectedStorageFiles()
  };

  $.post(ajax_url, data, function() {}).success(function() {}).fail(function(response) {});
});

During this request I've planned to do some checks:

  1. Does the file/files exists?
  2. Is the request valid?
  3. Is the encrypted filename saved in the DB?

If everything is true, I need to download the file somehow. I saw a plugin using query_vars by sending a result link to the browser which get's loaded and this downloads the file. Is this is a good idea? Or is there something better?

I've tried setting query vars but I'm not sure if this is secure enough and good because I only want to allow file download via my AJAX request and the checks there.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742360562a4429311.html

相关推荐

  • plugins - How can I create a secure file download in WordPress?

    I need you help. I'm currently trying to develop a secure file download in PHP and WordPress. I've already don

    2天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信