English Hello to everyone my name is eresbos, - How to create a limit file downloading with php? Türkçe Merhaba arkadaşlar ben eresbos.Bugün sizlere php ile dosya indirme işlemlerinde indirme hızı limiti nasıl konulur onu göstereceğim. - Kodlarımız ; ``` <?php $yerel_dosya = "deneme.zip"; $indirilecek_dosya = "indirilendosya.zip"; $indirme_hizi = 30; if(file_exists($yerel_dosya) && is_file($yerel_dosya)) { header("Content-Type: application/octet-stream"); header("Content-Length: ".filesize($yerel_dosya)); header("Content-Disposition: attachment; filename=" .$indirilecek_dosya); flush(); $dosya = fopen($yerel_dosya, "r"); while(!feof($dosya)) { print fread($dosya, round($indirme_hizi * 1024) ); flush(); sleep(1); } fclose($dosya); }else { echo 'Dosya mevcut degil'; } ?> ``` ![kodlar.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855555/gtocghekqoxp9hsqbjaz.png) 1- Projemiz için bir tane dosyaya ihtiyacımız var ben 4.36 mb boyutunda deneme.zip olarak oluşturdum ve localhosta attım.Sizde istediğiniz boyutta ve istediğiniz isimde dosya oluşturup localhosta atabilirsiniz. ![dosya.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514852733/xybbrzuqtu33kn03kjbh.png) 2- Değişkenlerimizi tanımlayalım; - ```$yerel_dosya = "deneme.zip"``` değişkeni localhostta bulunan dosyamızı tanıtmaya yarıyor. ![yerel_dosya.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853228/ajceimwhlmpu6630dya4.png) - ```$indirilecek_dosya = "indirilendosya.zip"``` dosyamızın indirme işlemi tamamlandığınca alacağı ismi tanıtmamızı sağlıyor. ![indirilecek_dosya.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853253/tes2nxfdsdl3cjlg3m8e.png) - ```$indirme_hizi = 30;``` indirme limitimizi belirlememizi sağlıyor.Yani saniyede maksimum 30 kilobyte indirmemizi sağlayacak. ![indirme_hizi.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853364/dbqp0whjxfyzwf6rjbrn.png) 3- Dosya kontrolümüzü yapıyoruz.'Eğer dosyamız varsa ve bu klasör değilse' şeklinde koşulumuzu yazıyoruz. ``` if(file_exists($yerel_dosya) && is_file($yerel_dosya)) { ``` ![dosya kontrolu.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853663/hp1cyubr11usfghexkim.png) 4- İndirme işlemini gerçekleştirmek için; - ```header("Content-Type: application/octet-stream");``` burada indirilecek dosyamızın tipini zip olarak belirliyoruz. - ```header("Content-Length: ".filesize($yerel_dosya));``` burada indirelecek dosyamızın boyutunu belirliyoruz. - ```header("Content-Disposition: attachment; filename=" .$indirilecek_dosya);``` burada indirme işlemimizi başlatmak ve indirirken hangi ismi kullanacağımızı belirlemek için yeni bir header yazıyoruz. ``` header("Content-Type: application/octet-stream"); header("Content-Length: ".filesize($yerel_dosya)); header("Content-Disposition: attachment; filename=" .$indirilecek_dosya); ``` ![headerlar.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854168/hjgvznnh8xobx7jpku4d.png) 5- ```flush();``` tarayıcıya gömme işlemimizi yapıyoruz. ![gömme.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854349/vqg1szyqngcfrkr1duyc.png) 6- ```$dosya = fopen($yerel_dosya, "r");``` dosyamızı açıp parça parça okutma işlemini gerçekleştiriyoruz. ![dosya açma.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854524/v6qylorgdvtovabe9azy.png) 7- ```while(!feof($dosya)) {``` while döngümüzü kuruyoruz, dosyanın sonuna kadar okunup okunmadığını kontrol ediyoruz. ![dosya okuma.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854679/f9zf2oba20e05yb1wjim.png) 8- ```print fread($dosya, round($indirme_hizi * 1024) );``` dosyamızı okuttuktan sonra 1024 ile çarpıp kilobyte değerini ekrana yazdırıyoruz. ![xxx.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854845/gdetatljfd1mjdxqzcik.png) 9- Tekrar ```flush();``` methoduyla tarayıcımıza gömüyoruz. ![gömme.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854940/e04kubvxm3relyjm6rhu.png) 10- ```sleep(1);``` sleep ile 1 saniye bekleme süresi koyuyoruz. ![sleep.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855004/lzocnyw00el7bwzeytof.png) 11- ```fclose($dosya);``` burada indirme işlemini tamamladıktan sonra fclose ile açtığımız dosyayı kapatıyoruz. ![kapatma.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855090/czfhxgyoru9b0b9bgmve.png) 12- ```}else {``` eğer üçüncü adımda yazdığımız koşul sağlanmıyorsa, ![else.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855167/qmeywlnlqas8dbvufir0.png) 13- ```echo 'Dosya mevcut degil';``` ekrana dosya mevcut değil sonucunu bastırıyoruz. Github link : https://github.com/php/php-src <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@eresbos/php-ile-dosya-indirme-islemini-limitlendirme-turkish-tutorial">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
post_id | 23,029,894 | ||||||
---|---|---|---|---|---|---|---|
author | eresbos | ||||||
permlink | php-ile-dosya-indirme-islemini-limitlendirme-turkish-tutorial | ||||||
category | utopian-io | ||||||
json_metadata | "{"type": "tutorials", "repository": {"id": 1903522, "watchers": 14041, "events_url": "https://api.github.com/repos/php/php-src/events", "forks": 4565, "name": "php-src", "issues_url": "https://api.github.com/repos/php/php-src/issues{/number}", "trees_url": "https://api.github.com/repos/php/php-src/git/trees{/sha}", "fork": false, "git_url": "git://github.com/php/php-src.git", "assignees_url": "https://api.github.com/repos/php/php-src/assignees{/user}", "size": 305504, "owner": {"id": 25158, "following_url": "https://api.github.com/users/php/following{/other_user}", "starred_url": "https://api.github.com/users/php/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/php/subscriptions", "repos_url": "https://api.github.com/users/php/repos", "login": "php", "gists_url": "https://api.github.com/users/php/gists{/gist_id}", "followers_url": "https://api.github.com/users/php/followers", "received_events_url": "https://api.github.com/users/php/received_events", "type": "Organization", "avatar_url": "https://avatars2.githubusercontent.com/u/25158?v=4", "site_admin": false, "organizations_url": "https://api.github.com/users/php/orgs", "gravatar_id": "", "events_url": "https://api.github.com/users/php/events{/privacy}", "url": "https://api.github.com/users/php", "html_url": "https://github.com/php"}, "forks_count": 4565, "git_refs_url": "https://api.github.com/repos/php/php-src/git/refs{/sha}", "blobs_url": "https://api.github.com/repos/php/php-src/git/blobs{/sha}", "pushed_at": "2017-12-31T12:04:09Z", "watchers_count": 14041, "teams_url": "https://api.github.com/repos/php/php-src/teams", "comments_url": "https://api.github.com/repos/php/php-src/comments{/number}", "archived": false, "svn_url": "https://github.com/php/php-src", "merges_url": "https://api.github.com/repos/php/php-src/merges", "subscribers_url": "https://api.github.com/repos/php/php-src/subscribers", "issue_events_url": "https://api.github.com/repos/php/php-src/issues/events{/number}", "stargazers_url": "https://api.github.com/repos/php/php-src/stargazers", "mirror_url": null, "statuses_url": "https://api.github.com/repos/php/php-src/statuses/{sha}", "has_projects": false, "milestones_url": "https://api.github.com/repos/php/php-src/milestones{/number}", "description": "The PHP Interpreter", "keys_url": "https://api.github.com/repos/php/php-src/keys{/key_id}", "open_issues": 133, "compare_url": "https://api.github.com/repos/php/php-src/compare/{base}...{head}", "ssh_url": "git@github.com:php/php-src.git", "license": {"name": "Other", "key": "other", "url": null, "spdx_id": null}, "html_url": "https://github.com/php/php-src", "commits_url": "https://api.github.com/repos/php/php-src/commits{/sha}", "open_issues_count": 133, "stargazers_count": 14041, "branches_url": "https://api.github.com/repos/php/php-src/branches{/branch}", "full_name": "php/php-src", "forks_url": "https://api.github.com/repos/php/php-src/forks", "score": 149.17505, "deployments_url": "https://api.github.com/repos/php/php-src/deployments", "contributors_url": "https://api.github.com/repos/php/php-src/contributors", "homepage": "http://www.php.net", "contents_url": "https://api.github.com/repos/php/php-src/contents/{+path}", "has_downloads": true, "collaborators_url": "https://api.github.com/repos/php/php-src/collaborators{/collaborator}", "created_at": "2011-06-16T01:52:25Z", "git_commits_url": "https://api.github.com/repos/php/php-src/git/commits{/sha}", "releases_url": "https://api.github.com/repos/php/php-src/releases{/id}", "private": false, "pulls_url": "https://api.github.com/repos/php/php-src/pulls{/number}", "git_tags_url": "https://api.github.com/repos/php/php-src/git/tags{/sha}", "notifications_url": "https://api.github.com/repos/php/php-src/notifications{?since,all,participating}", "language": "C", "updated_at": "2017-12-31T12:57:25Z", "has_wiki": false, "downloads_url": "https://api.github.com/repos/php/php-src/downloads", "hooks_url": "https://api.github.com/repos/php/php-src/hooks", "languages_url": "https://api.github.com/repos/php/php-src/languages", "default_branch": "master", "labels_url": "https://api.github.com/repos/php/php-src/labels{/name}", "url": "https://api.github.com/repos/php/php-src", "has_pages": false, "tags_url": "https://api.github.com/repos/php/php-src/tags", "clone_url": "https://github.com/php/php-src.git", "archive_url": "https://api.github.com/repos/php/php-src/{archive_format}{/ref}", "has_issues": false, "issue_comment_url": "https://api.github.com/repos/php/php-src/issues/comments{/number}", "subscription_url": "https://api.github.com/repos/php/php-src/subscription"}, "pullRequests": [], "format": "markdown", "image": ["https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855555/gtocghekqoxp9hsqbjaz.png"], "links": ["https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855555/gtocghekqoxp9hsqbjaz.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514852733/xybbrzuqtu33kn03kjbh.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853228/ajceimwhlmpu6630dya4.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853253/tes2nxfdsdl3cjlg3m8e.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853364/dbqp0whjxfyzwf6rjbrn.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514853663/hp1cyubr11usfghexkim.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854168/hjgvznnh8xobx7jpku4d.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854349/vqg1szyqngcfrkr1duyc.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854524/v6qylorgdvtovabe9azy.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854679/f9zf2oba20e05yb1wjim.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854845/gdetatljfd1mjdxqzcik.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514854940/e04kubvxm3relyjm6rhu.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855004/lzocnyw00el7bwzeytof.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855090/czfhxgyoru9b0b9bgmve.png", "https://res.cloudinary.com/hpiynhbhq/image/upload/v1514855167/qmeywlnlqas8dbvufir0.png"], "app": "utopian/1.0.0", "moderator": {"flagged": false, "account": "sedatyildiz", "reviewed": true, "pending": false}, "platform": "github", "tags": ["utopian-io", "utopian-io", "tr"], "community": "utopian"}" | ||||||
created | 2018-01-02 01:13:21 | ||||||
last_update | 2018-01-06 22:20:33 | ||||||
depth | 0 | ||||||
children | 2 | ||||||
net_rshares | 3,116,497,506,608 | ||||||
last_payout | 2018-01-09 01:13:21 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 21.271 SBD | ||||||
curator_payout_value | 9.137 SBD | ||||||
pending_payout_value | 0.000 SBD | ||||||
promoted | 0.000 SBD | ||||||
body_length | 4,904 | ||||||
author_reputation | 389,045,144,994 | ||||||
root_title | "php ile dosya indirme işlemini limitlendirme (turkish tutorial)" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 SBD | ||||||
percent_steem_dollars | 10,000 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
nanokat | 0 | 418,104,800 | 100% | ||
logoped | 0 | 415,030,500 | 100% | ||
ribalko26 | 0 | 415,030,500 | 100% | ||
buynichenko | 0 | 402,733,300 | 100% | ||
bushkov | 0 | 391,111,222 | 100% | ||
evsyucko | 0 | 405,158,805 | 100% | ||
kirill.shulko | 0 | 418,573,079 | 100% | ||
svesenet | 0 | 395,994,367 | 100% | ||
kubr | 0 | 399,659,000 | 100% | ||
eslavnash | 0 | 406,111,200 | 100% | ||
leichenvera | 0 | 409,187,800 | 100% | ||
balalayka | 0 | 406,111,200 | 100% | ||
dennyse | 0 | 392,561,236 | 100% | ||
pushkinant | 0 | 421,494,200 | 100% | ||
zurrovani | 0 | 393,804,800 | 100% | ||
livochkin | 0 | 399,958,000 | 100% | ||
gddg42 | 0 | 384,575,000 | 100% | ||
sinankarayaman | 0 | 2,379,833,362 | 100% | ||
irisarma | 0 | 387,361,800 | 100% | ||
korosten | 0 | 403,034,600 | 100% | ||
dayjee | 0 | 13,964,733,864 | 100% | ||
irina00 | 0 | 390,436,100 | 100% | ||
mutov | 0 | 417,120,068 | 100% | ||
deerty | 0 | 399,087,904 | 100% | ||
utopian-io | 0 | 3,087,330,627,702 | 1.81% | ||
odl | 0 | 2,382,008,819 | 100% | ||
itrioilamoricle | 0 | 407,568,870 | 100% | ||
javatorman | 0 | 1,160,494,510 | 100% |
Thank you for the contribution. It has been approved. You can contact us on [Discord](https://discord.gg/UCvqCsx). **[[utopian-moderator]](https://utopian.io/moderators)**
post_id | 23,229,051 |
---|---|
author | sedatyildiz |
permlink | re-eresbos-php-ile-dosya-indirme-islemini-limitlendirme-turkish-tutorial-20180103t035809488z |
category | utopian-io |
json_metadata | "{"app": "utopian/1.0.0", "community": "utopian", "tags": ["utopian-io"]}" |
created | 2018-01-03 03:58:12 |
last_update | 2018-01-03 04:19:21 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2018-01-10 03:58:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 172 |
author_reputation | 4,387,551,450,260 |
root_title | "php ile dosya indirme işlemini limitlendirme (turkish tutorial)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
### Hey @eresbos I am @utopian-io. I have just upvoted you! #### Achievements - You have less than 500 followers. Just gave you a gift to help you succeed! - Seems like you contribute quite often. AMAZING! #### Suggestions - Contribute more often to get higher and higher rewards. I wish to see you often! - Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck! #### Get Noticed! - Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
post_id | 23,472,455 |
---|---|
author | utopian-io |
permlink | re-eresbos-php-ile-dosya-indirme-islemini-limitlendirme-turkish-tutorial-20180104t072109438z |
category | utopian-io |
json_metadata | "{"app": "utopian/1.0.0", "community": "utopian", "tags": ["utopian-io"]}" |
created | 2018-01-04 07:21:09 |
last_update | 2018-01-04 07:21:09 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2018-01-11 07:21:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 1,505 |
author_reputation | 152,913,012,544,965 |
root_title | "php ile dosya indirme işlemini limitlendirme (turkish tutorial)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |