怎么判断一个文件被客户端成功上载
如何判断一个文件被客户端成功下载
rt,如何能够确认文件被客户端成功下载?
------解决方案--------------------
一般情况下当输出完头以后就直接将整个文件输出出去
通常用的是 ceho、print 有的干脆用 readfile
这样 php 就没有机会去判断用户是否终止了下载
你需要在循环中用较小的块,通过 sprintf 输出文件内容
springf 函数会返回一个表示输出了多少字符的数。你可以累计这个数,并与文件长度进行比较
从而判断下载是否完成
------解决方案--------------------
基本上是没法判断的。。。
------解决方案--------------------
基于http是没办法做到的。比如服务器返回了2000个字节让你下载保存,这时候你在你在浏览器点了取消按钮,或者下载到一半取消,再或者下载完成,这些个动作只在客户端浏览器执行,并不会将状态通知服务器。
------解决方案--------------------
说的不对,应该说基于浏览器的客户端无法做到,下载保存那些动作是浏览器帮你处理的。
如果说你自己写个客户端,很容易可以判断,计算返回字节数,统计保存成文件的字节数两个一比较就行。
------解决方案--------------------
IE下可使用ActiveX,FireFox下可以使用NPAPI
------解决方案--------------------
一般来讲,要判断文件下载完毕的话需要通过控件来实现。普通的JS是没法判断的。
------解决方案--------------------
强,这个不错。最近我们公司也在做一个OA项目,也要判断文件下载完成的事件,正需要一个这样的HTTP文件下载控件,能否把地址发一下。谢谢。
------解决方案--------------------
这个好像是Xproer.HttpDownloader。可以在网上直接搜到。
------解决方案--------------------
如果是通过PHP页面下载的话可以在PHP页面中直接判断。如果想在客户端判断的话,需要借助于插件来实现。
------解决方案--------------------
我们之前给政府做的一个文档管理类的项目也是用的这个控件。感觉不错。整合也简单。
------解决方案--------------------
是吗?是否要给你段代码看看才相信?
------解决方案--------------------
send_file 函数是在网上找的,写的并不好,但他确能保证数据不丢失
在此基础上做了些改动,代码中有注释
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

HTTP status code 520 means that the server encountered an unknown error while processing the request and cannot provide more specific information. Used to indicate that an unknown error occurred when the server was processing the request, which may be caused by server configuration problems, network problems, or other unknown reasons. This is usually caused by server configuration issues, network issues, server overload, or coding errors. If you encounter a status code 520 error, it is best to contact the website administrator or technical support team for more information and assistance.

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

In iOS 17, Apple introduced several new privacy and security features to its mobile operating system, one of which is the ability to require two-step authentication for private browsing tabs in Safari. Here's how it works and how to turn it off. On an iPhone or iPad running iOS 17 or iPadOS 17, Apple's browser now requires Face ID/Touch ID authentication or a passcode if you have any Private Browsing tab open in Safari and then exit the session or app to access them again. In other words, if someone gets their hands on your iPhone or iPad while it's unlocked, they still won't be able to view your privacy without knowing your passcode

The famous activation script MAS2.2 version supports digital activation again. The method originated from @asdcorp and the team. The MAS author calls it HWID2. Download gatherosstate.exe (not original, modified) from https://github.com/massgravel/Microsoft-Activation-Scripts, run it with parameters, and generate GenuineTicket.xml. First take a look at the original method: gatherosstate.exePfn=xxxxxxx;DownlevelGenuineState=1 and then compare with the latest method: gatheros

Editor of Machine Power Report: Wu Xin The domestic version of the humanoid robot + large model team completed the operation task of complex flexible materials such as folding clothes for the first time. With the unveiling of Figure01, which integrates OpenAI's multi-modal large model, the related progress of domestic peers has been attracting attention. Just yesterday, UBTECH, China's "number one humanoid robot stock", released the first demo of the humanoid robot WalkerS that is deeply integrated with Baidu Wenxin's large model, showing some interesting new features. Now, WalkerS, blessed by Baidu Wenxin’s large model capabilities, looks like this. Like Figure01, WalkerS does not move around, but stands behind a desk to complete a series of tasks. It can follow human commands and fold clothes

HTTP status code 403 means that the server rejected the client's request. The solution to http status code 403 is: 1. Check the authentication credentials. If the server requires authentication, ensure that the correct credentials are provided; 2. Check the IP address restrictions. If the server has restricted the IP address, ensure that the client's IP address is restricted. Whitelisted or not blacklisted; 3. Check the file permission settings. If the 403 status code is related to the permission settings of the file or directory, ensure that the client has sufficient permissions to access these files or directories, etc.
