Link to home
Create AccountLog in
Avatar of te-edu
te-eduFlag for Serbia

asked on

Check if download is interupted and check filesize OS independent

I build php based download/upload remote upload/reupload/download server using curl. I manage almost everything. Working with http, https, ftp and ftps protocols.  Script download any file from remote server and output it as force/download, inline etc. Now I adding option if you download some file from remote server to make local copy on server where is script hosted. That work also.

What I can not solve for now is:

1. Is there any workaround to detect when user stop download. EG. Script support resume download, rage, multi range and chunked downloads.

- I do it with time difference and packet output, but I do not like it, hight load server and must check every loop because I use CURLOPT_WRITEFUNCTION and callback.

- Also there are if(connection_aborted() || connection_status() == 0) , but not working with Chrome. In Firefox is working with too long timeout.

2. Other thing is I want to delete file if download is incomplete. For original filesize I use curl_$this->getStatus = getinfo($curl); and for local copy filesize()

	if(filesize($this->local_copy.(rawurldecode($this->fileName))) !== $this->getStatus['download_content_length']){

Open in new window

But every time file is unlinked no matter of real file size limits for files >2GB with php filesize function.

Thanks in advance!!!
Avatar of te-edu
Flag of Serbia image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of te-edu


I find myself solution for this problem, also I publish solution to help others.