• <tfoot id='uu0hJ'></tfoot>

    • <bdo id='uu0hJ'></bdo><ul id='uu0hJ'></ul>

    1. <legend id='uu0hJ'><style id='uu0hJ'><dir id='uu0hJ'><q id='uu0hJ'></q></dir></style></legend>
      <i id='uu0hJ'><tr id='uu0hJ'><dt id='uu0hJ'><q id='uu0hJ'><span id='uu0hJ'><b id='uu0hJ'><form id='uu0hJ'><ins id='uu0hJ'></ins><ul id='uu0hJ'></ul><sub id='uu0hJ'></sub></form><legend id='uu0hJ'></legend><bdo id='uu0hJ'><pre id='uu0hJ'><center id='uu0hJ'></center></pre></bdo></b><th id='uu0hJ'></th></span></q></dt></tr></i><div id='uu0hJ'><tfoot id='uu0hJ'></tfoot><dl id='uu0hJ'><fieldset id='uu0hJ'></fieldset></dl></div>

      1. <small id='uu0hJ'></small><noframes id='uu0hJ'>

        上传到 FTP 时保留图像创建日期

        时间:2023-06-04
          <bdo id='GyhuN'></bdo><ul id='GyhuN'></ul>
        • <tfoot id='GyhuN'></tfoot>
            <tbody id='GyhuN'></tbody>

          <small id='GyhuN'></small><noframes id='GyhuN'>

            <i id='GyhuN'><tr id='GyhuN'><dt id='GyhuN'><q id='GyhuN'><span id='GyhuN'><b id='GyhuN'><form id='GyhuN'><ins id='GyhuN'></ins><ul id='GyhuN'></ul><sub id='GyhuN'></sub></form><legend id='GyhuN'></legend><bdo id='GyhuN'><pre id='GyhuN'><center id='GyhuN'></center></pre></bdo></b><th id='GyhuN'></th></span></q></dt></tr></i><div id='GyhuN'><tfoot id='GyhuN'></tfoot><dl id='GyhuN'><fieldset id='GyhuN'></fieldset></dl></div>

                • <legend id='GyhuN'><style id='GyhuN'><dir id='GyhuN'><q id='GyhuN'></q></dir></style></legend>
                  本文介绍了上传到 FTP 时保留图像创建日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  所以我正在为我的家人创建一个网站,我们可以在其中上传我们的图像并查看它们,但该网站的一个重要功能是按日期排序,以便例如当我的阿姨在我母亲的生日和我也拍了照片,我们上传它们将添加到同一个相册等的图像.

                  我意识到通过浏览器上传时无法保留日期.所以我会做一个只用于上传图片的小程序.我有一个 FTP 服务器正在运行,但是当我上传图像时,日期将更改为当前日期时间.我找到了为什么这样做的答案 所以现在我正在寻找一种在上传到 FTP 时保留日期的方法.

                  以下是我的一些想法:

                  1. 如果程序将文件添加到 zip 文件并上传该 zip 文件,它们将保留日期,但这意味着我必须在服务器上安装一些东西来解压 zip.
                  2. 上传图片后,程序会从原始图片中提取创建日期,并将其添加到一个文本文件中,该文件也会上传,但这需要服务器上的程序更改上传的图片创建日期.
                  3. 也许我上传了图片,然后从客户端更改了上传图片的创建日期?

                  解决方案

                  1. 也许我上传了图片,然后从客户端更改了上传图片的创建日期?

                  在 FTP 协议中,使用 MFMTMDTM 命令更新文件修改时间戳,或 MFCT 更新文件创建时间戳,具体取决于哪个您的 FTP 服务器支持的这些.

                  实际上没有一个是标准化的.

                  • MFMTMFCT 在此起草:
                    https://datatracker.ietf.org/doc/html/草稿-somers-ftp-mfxx-04
                  • MDTM 在 RFC 3659 中定义为检索文件修改时间戳,使用 MDTM 文件名 语法.但许多 FTP 服务器也支持替代(非标准)语法 MDTM 文件名时间戳(即与提议的 MFMT 相同)来更新修改时间戳.

                  尽管 .NET 框架中的本机 FTP 实现(FtpWebRequestWebClient 包装器)不支持其中任何一个.

                  您必须使用第 3 方库.

                  例如,WinSCP .NET 程序集会自动为任何上传(或下载),无需任何额外代码.

                  上传文件的简单示例代码(隐式保留修改时间戳):

                  //设置会话选项SessionOptions sessionOptions = 新的 SessionOptions{协议 = Protocol.Ftp,主机名 = example.com",用户名 = 用户",密码=我的密码",};使用(会话会话 = 新会话()){//连接session.Open(sessionOptions);//上传session.PutFiles(@"d:	ouploadimage.jpg", "/home/user/").Check();}

                  有关详细信息,请参阅 Session.PutFiles.p>

                  最新版本的 WinSCP GUI FTP 客户端(5.9 及更高版本)甚至可以生成 C# 代码给你.

                  (我是 WinSCP 的作者)

                  So I am making a website for my family, where we can upload our images and view them, but an important feature of the website is to sort by date so that when for example my aunt have taken pictures at my mothers birthday and I also have taken pictures and we upload the images they will be added to the same album etc.

                  I've realized that it is not possible to preserve the date, when uploading through a browser. So I will make a small program which is only used for upload pictures. I have an FTP server running but when ever I upload images the date will change to current datetime. I have found the answer to why it does that so now I am looking for a way to preserve the date while uploading to FTP.

                  Here's some ideas I've had:

                  1. If the program adds the files to a zip file and upload that zip file they will preserve the date, but that means I would have to have something on the server that unpacks the zips.
                  2. When the images gets uploaded the program extracts the created date from the original image and adds it to a text file which it also uploads, but that would again require a program on the server which changes the uploaded images created date.
                  3. Maybe I upload the images and thereafter change the uploaded images created date from the client?

                  解决方案

                  1. Maybe I upload the images and thereafter change the uploaded images created date from the client?

                  In FTP protocol, use MFMT or MDTM command to update file modification timestamp, or MFCT to update file creation timestamp, depending on which of these your FTP server supports.

                  Actually none of them is standardized.

                  • The MFMT and MFCT are drafted here:
                    https://datatracker.ietf.org/doc/html/draft-somers-ftp-mfxx-04
                  • The MDTM is defined in RFC 3659 to retrieve file modification timestamp, using MDTM filename syntax. But many FTP servers support an alternative (non-standard) syntax MDTM filename timestamp (i.e. the same as proposed MFMT) to update the modification timestamp too.

                  Though the native FTP implementation in .NET framework (the FtpWebRequest or the WebClient wrapper), does not support any of these.

                  You have to use a 3rd party library.

                  For example the WinSCP .NET assembly preserves the modification timestamp automatically for any upload (or download) without any additional code.

                  A simple example code to upload a file (implicitly preserving the modification timestamp):

                  // Setup session options
                  SessionOptions sessionOptions = new SessionOptions
                  {
                      Protocol = Protocol.Ftp,
                      HostName = "example.com",
                      UserName = "user",
                      Password = "mypassword",
                  };
                  
                  using (Session session = new Session())
                  {
                      // Connect
                      session.Open(sessionOptions);
                  
                      // Upload
                      session.PutFiles(@"d:	ouploadimage.jpg", "/home/user/").Check();
                  }
                  

                  For details, see Session.PutFiles.

                  The latest version of WinSCP GUI FTP client (5.9 and newer) can even generate the C# code for you.

                  (I'm the author of WinSCP)

                  这篇关于上传到 FTP 时保留图像创建日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 FluentFTP 从 FTP 并发下载多个文件,最大值 下一篇:如何将存储在 FTP 服务器上的 ZIP 文件中的数据导

                  相关文章

                  最新文章

                • <tfoot id='9OtOO'></tfoot>

                • <legend id='9OtOO'><style id='9OtOO'><dir id='9OtOO'><q id='9OtOO'></q></dir></style></legend>
                  1. <i id='9OtOO'><tr id='9OtOO'><dt id='9OtOO'><q id='9OtOO'><span id='9OtOO'><b id='9OtOO'><form id='9OtOO'><ins id='9OtOO'></ins><ul id='9OtOO'></ul><sub id='9OtOO'></sub></form><legend id='9OtOO'></legend><bdo id='9OtOO'><pre id='9OtOO'><center id='9OtOO'></center></pre></bdo></b><th id='9OtOO'></th></span></q></dt></tr></i><div id='9OtOO'><tfoot id='9OtOO'></tfoot><dl id='9OtOO'><fieldset id='9OtOO'></fieldset></dl></div>

                    <small id='9OtOO'></small><noframes id='9OtOO'>

                        <bdo id='9OtOO'></bdo><ul id='9OtOO'></ul>