File Not download completely - download

I have written code to download audio files. When I try to download a file more than 50MB through PHP, it does not download completely. It downloads a maximum of 45MB. Every time I try to download, the download size varies from 36MB to 45MB.
I have changed the configuration in php.ini as follows:
memory_limit 512M
post_max_size 512M
upload_max_filesize 512M
In phpinfo(), its show the above value after I change the configuration. Still I have the same problem.
I use the following code to download:
<?php
$file = "file to download";
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
?>
Help me to resolve this
Thanks

Anyone have idea on this? I use Download Manager to download a file . When it reach 65% it shows Error message as "Data Transfer has been interrupted and the server doesnot support resume. Its only possible to download from the beginning"..
How to resolve this?

Related

Why my custom validation is not working in laravel? [duplicate]

I am getting this error when trying to upload an import on WordPress on my XAMPP local dev environment:
Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
I changed the upload_max_filesize from 2M to 1000M, but that didn't seem to do anything.
Any ideas?
8388608 bytes is 8M, the default limit in PHP. Update your post_max_size in php.ini to a larger value.
upload_max_filesize sets the max file size that a user can upload while
post_max_size sets the maximum amount of data that can be sent via a POST in a form.
So you can set upload_max_filesize to 1 meg, which will mean that the biggest single file a user can upload is 1 megabyte, but they could upload 5 of them at once if the post_max_size was set to 5.
Changes will take effect after a restart of the server.
Just set these in php.ini:
upload_max_filesize = 1000M;
post_max_size = 1000M;
1. First u will find the php.ini file.
u can find php.ini file from this path. C:\xampp\php or from
xampp folder.
2. Now open php.ini file and change the following:
1. post-max-size (change 8M to 800M).
2. upload-max-filesize (change 2M to 2000M).
3. Now stop the Apache server and MySQL.
4. Now restart Apache server and MySQL.
It worked fine after that.
Enjoy ur working now :)
That's an 8MB post_max_size error.
Set it to a value you're comfortable with.
You will have to change the value of
post-max-size
upload-max-filesize
both of which you will find in php.ini
Restarting your server will help it start working. On a local test server running XAMIP, i had to stop the Apache server and restart it. It worked fine after that.
Already restarted your Webserver?
This will force php to reload the php.ini
Go to C:\xamppp\php. Set these values in php.ini:
upload_max_filesize = 1000M
post_max_size = 0M
Create new text file in your wp-admin directory root and name it info.php.
Open info.php and add this line:
<?php phpinfo(); ?>
Save it.
Go to yourwebsitename(probably localhost)/wp-admin/info.php in any web-browser.
On the 8th line you will see: Configuration File (php.ini) Path, in my case it is C:\Windows, meaning it is located on my C drive.
In the 9th line you will see: Loaded Configuration File, and next to it is written C:\xampp\php.ini
So I found my php.ini page that is associated with my wordpress web-site.
Go to that path, and find php.ini.
Open it, and edit:
Search for post_max_size=8M, and change it to post_max_size=1000M
Search for upload_max_filesize=2M, and change it to upload_max_filesize=1000M
Go back to your Admin page → Media → Add New
On the bottom you will see that 2MB has changed to 1000M.
Once you done this process then you must restart your web server or just restart your computer.
Find php.ini [\xampp\php]
Just set these in php.ini:
upload_max_filesize = 1000M;
post_max_size = 1000M;
Rebot server
Stop Apache and MySQL
Start again Apache and MySQL
Go to
C:\drive\xampp(where xampp installed)
simply find php.ini file then in the file search
post_max_size=XXM
upload_max_size=XXM
Change with this code
post_max_size=100M
upload_max_filesize=100M
Don't forget to restart the xampp
Using wamp do the following and hopefully, it will resolve an issue
Make these changes in PHP Options to correct:
max_execution_time 180
memory_limit 512M or your highest available
post_max_size 32M
upload_max_filesize 64M
You also need the change post-max-size.
From the XAMPP panel, click on the ADMIN button on the Apache site.
Then choose to edit php.ini
And add the missing post_max_size to a value you are comfortable with.
post_max_size = 100M
Go to
C:\ drive
or that drive where xampp is installed
click on xampp
find php and open it , there you find php.ini folder
open php.ini file with notepad and find upload_max_filesize and post_max_size in both "up and down find option",change both values to 1000M
I have fixed same issue by changing below parameters to expected value in /etc/php/7.2/apache2/php.ini file
upload_max_filesize = 8M;
post_max_size = 8M;
upload_max_filesize = 8M;
post_max_size = 8M;
Imagine you already changed above values. But what happen when user try to upload large files greater than 8M ?
This is what happen, PHP shows this warning!
Warning: POST Content-Length of x bytes exceeds the limit of y bytes in Unknown on line 0
you can avoid it by adding
ob_get_contents();
ob_end_clean();
You have 2 options for this error:
The file you are uploading is too big, which you need to use smaller file.
Increase the upload size in php.ini to
upload_max_filesize = 9M; post_max_size = 9M;
Go to browser and search for php.ini and then open it, and change these two values:
post_max_size= 1000000000000M
upload_max_filesize= 10000000000000M
If you open the php.ini file using notepad , you can search for these two values by clicking:
cmd + f
You might not be uploading the right zip file. In my case, as a newbie to wordpress(I used to do hardcoding), I installed the zipped file that contained another zip file which is the actual theme neede to be upload. So what what need to do in this case is to unzip the file and locate the "theme_name.zip" inside.
If changing the post_max_size settings from XAMPP folders. It did not work for you try this.
From XAMPP control panel, click config then PHP (php.ini) and edit post_max_size and upload_max_filesize to a higher number in this file instead. Stop Apache server. Start Apache server. This worked for me.
If your objective is to import a theme into your Wordpress then you can manually copy paste your theme into your wp-content->themes folder and extract it of course. I just encountered this and couldn't locate the php.ini file for WAMP.
I have solved my php7 issues on centos 7 by updating /etc/php.ini with these settings:
post_max_size = 500M
upload_max_filesize = 500M
As Optimaz ID pointed out, the code below helped me hide the PHP error message in a case where the user uploads a file larger than the upload_max_filesize and post_max_size set in php.ini (which is almost impossible when a large value is set).
ob_get_contents();
ob_end_clean();
for anyone running PHPMyAdmin inside of docker.
Set the UPLOAD_LIMIT value in the env
from the docs https://github.com/phpmyadmin/docker#environment-variables-summary
UPLOAD_LIMIT - if set, this option will override the default value
for apache and php-fpm (format as [0-9+](K,M,G) default value is
2048K, this will change upload_max_filesize and post_max_size
values)
docker-compose.yml example:
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
- UPLOAD_LIMIT=300M
normal docker run:
sudo docker run .... -e UPLOAD_LIMIT=300M
For both of these options you have to rebuild the container

How disable XAMPP or PHP caching?

After I reinstalled XAMPP and copied the projects folder into htdocs and ran the script to create the database I have a rare case of cache. This is something that I have done on other occasions without problems.
Regardless of the changes you make to the code, a previous version is always displayed without the changes.
I clean the browser cache... no changes. I ruled out that the problem was in the browser, because I used two other browsers where I had never opened the page and the version showed is the same without the changes.
In PHP I have the headers to avoid the cache:
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); // HTTP/1.1
header('Pragma: no-cache');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
In httpd.conf I commented the line of:
LoadModule cache_module modules/mod_cache.so
Without success... I installed an older version of XAMPP and the problem remains.
Some suggestion, please??
Regards

Laravel: I cant upload videos

I am trying to upload videos using Laravel. I get following error:
Warning: POST Content-Length of 17500298 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
I changed param in php.ini of my xampp local server:
upload_max_filesize
But I get the same error as shown above.
You need to fix these values inside php.ini first
upload_max_filesize = ??M
post_max_size = ??M
and then make
dd(phpinfo());
somewhere in your code and see where is that php.ini file your server uses
and if those values are applied!

Error uploading new template in extension manager in joomla

Getting the following error:
Error
There was an error uploading this file to the server.
Maximum PHP file upload size is too small: This is set in php.ini in both upload_max_filesize and post_max_size settings of your PHP settings (located in php.ini and/or .htaccess file).
Unable to find install package
I have open the ini file but didnt find any size options in this file
Locate the php.ini of the apache server or watever you are using.
add the following lines in it.
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
You can view it in phpinfo or in global configuration of joomla PHP settings.

Laravel 3 Snappy bundle Class Snappy not found

I'm struggling to get the Snappy bundle to work.
It keeps telling me that the Snappy Class is not found.
I've installed the bundle and added it to the bundles.php file for auto loading.
But still nothing.
All help is appreciated :) Thanks
I found the solution,
I had everything installed correctly but the issue was I should be using namespaces. On the bundle page it says the usage is something like this.
Bundle::start('snappy');
$snappy = Snappy::make('/usr/bin/wkhtmltopdf');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="file.pdf"');
echo $snappy->getOutput('http://laravel.com');
exit;
The correct way to do this is to use the namespace like so
Bundle::start('snappy');
// the following two lines is added
use Knp\Snappy\Pdf;
$snappy = new Pdf('/usr/local/bin/wkhtmltopdf');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="file.pdf"');
echo $snappy->getOutput('http://laravel.com');
exit;
If you have installed the bundle using Artisan then (from a quick look at the bundles GitHub repository) you need to rename the folder bundles/snappy-laravel-bundle to just snappy. Or you can add in a location key in the bundles registration in application/bundles.php.
'snappy' => array('auto' => true, 'location' => 'snappy-laravel-bundle')
Laravel, by default, will assume that the key of the array (in this case snappy) is the directory that the bundle is stored in in the bundles directory.

Resources