文件上传:如何在外部云文件夹中上传文件javascript修改 [英] File-upload: how to upload files in an external cloud folder javascript modification

查看:672
本文介绍了文件上传:如何在外部云文件夹中上传文件javascript修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 .js 为了上传文件并且显示上传的文件的列表。我有两个问题:

I have this .js in order to upload a file and show a list of the uploaded files. I have 2 problems:


  1. 如何显示列出的文件不是按字母顺序,而是按照上传的顺序?

  2. 我知道可以将这些文件加载​​到保管箱或驱动器文件夹而不是服务器中的文件夹中,我该如何做?

感谢

<!DOCTYPE html>
<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
<?php
if (isset($_POST['submit'])) 
{
echo 'succesfully uploaded';
$structure = 'uploadedfiles/';
$target_file = $structure.basename($_FILES["fileToUpload"]["name"]);
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
}
$dir    = 'up/';
$files = scandir($dir);
echo '<h1>List of Uploaded Files</h1> <br><hr>';
$i = 1;
foreach ($files as $key) 
{
    if ($i>3) 
    {
    $j = $i-3;
    echo $j."<a href='up/".$key."'>".$key."</a><hr>";
    }
    $i++;

}
echo 'End of Files';

?>


推荐答案


  1. 您指的是您自己网站上显示的文件列表,您需要在某个持久性列表中维护所需的顺序,或者在向用户显示文件列表之前根据所需的任何条件对它们进行排序。 (例如,基于从文件系统修改的时间等)

  1. If you're referring to the list of files shown on your own site, you'll want to maintain the desired order in some persistent list somewhere, or sort them based on whatever criteria you want, before showing the list of files to the user. (E.g., based on the modified time from the filesystem, etc.)

要以编程方式将文件上传到Dropbox,您需要使用Dropbox API:

To upload files to Dropbox programmatically, you'll need to use the Dropbox API:

https://www.dropbox.com/developers/core

这里有一个官方的PHP SDK:

There's an official PHP SDK here:

  • download
  • tutorial
  • documentation

这篇关于文件上传:如何在外部云文件夹中上传文件javascript修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆