CSV download is not working Magento 1.9.2.3 - magento-1.9

I had created a module in magento to export some custom data for customer in excel sheet and when the user clicks on link it used to get exported and downloaded but now its stopped working suddenly. I see the file being created in my var folder but its not getting downloaded whatsoever
$csv->saveData($fileName, $customersArray);
$this->_prepareDownloadResponse($fileName, array('type' => 'filename', 'value' => $fileName));
$this->loadLayout();
$this->_title($this->__("Customer Export"));
$this->renderLayout();

What is the file size ?
As you said that you can see the file being created in your var folder but user can't download it, it may probably due to the PHP or web server settings.
Concerning php configuration, try to update your php.ini file with:
Upload_max_filesize = 1500 M
Max_input_time = 1000
Memory_limit = 640M
Max_execution_time = 1800
Post_max_size = 2000 M
Save your php.ini and restart your server.
source: this answer
If it is not the server, you may also add this line to your index.php file (or your main script file):
ini_set('upload_max_filesize', '1500M');
ini_set('memory_limit', '640M');
You may also add or modify the .htaccess file in the download directory (/var/download) with this:
<Files *.*>
ForceType applicaton/octet-stream
</Files>

Related

Is there a standard way to get LOAD INFILE working?

Load data infile has always been a pain in the ass to set up and there does not seem to be standard way to get it to work but I have always been able to get it to work ….eventually except now.
I am struggling with
Error Code: 29. File '/loadinfile/file.csv' not found (OS errno 13 - Permission denied)
The system is as follows:
MySQL version 8.0.29-0ubuntu0.22.04.2
Ubuntu 22.04
The load file directory is owned by mysql:mysql and same with the file and I have tried chmod 757 and even 777
In the config file I have tried the following variations:
secure_file_priv = "/loadinfile/"
secure_file_priv = '/loadinfile/'
secure_file_priv = ""
secure_file_priv = ''
The following is also set :
[mysqld]
local-infile = 1
[client]
loose-local-infile=1
Changing
LOAD DATA INFILE '/loadinfile/file.csv' INTO TABLE table
to
LOAD DATA LOCAL INFILE '/loadinfile/file.csv' INTO TABLE table
changes the error message to:
Error Code: 2. File '\loadinfile\file.csv' not found (OS errno 2 - No such file or directory)
Error Code: 2. File '\loadinfile\file.csv' not found (OS errno 2 - No such file or directory)
Above message indicates that your directory where the file is located is wrong! You must define the full path:
For example In Mac If your file resides on Desktop,It must be like this :
LOAD DATA LOCAL INFILE '/Users/computer_name/Desktop/filename.file_extension' INTO TABLE table
In windows
LOAD DATA LOCAL INFILE 'C:\Users\computer_name\Desktop\filename.file_extension' INTO TABLE table
I hope It solves your problem.
Error Code: 2. indicates invalid file path. Keep the LOCAL INFILE option and either specify the full path of the CSV file or make sure the CSV file path is correct. give it a try with Full path and see if it solves the problem or not.
From MySQL Docs
If LOCAL is specified, the file must be located on the client host.
The client program reads the file, locating it as follows:
If the file name is an absolute path name, the client program uses it
as given.
If the file name is a relative path name, the client program looks for
the file relative to its invocation directory
Edited
Make sure your mysqld.cnf or your main MySQL config file has the following variables
secure_file_priv = ""
local_infile=1
And your Global variable local_infile is OFF, turn it ON.
you can check that if you run this query
SHOW GLOBAL VARIABLES LIKE 'local_infile';
if it is OFF, turn it ON
And lastly, Make sure you restart your SQL service to reflect the changes. you can do that if you execute
service mysql restart
Hope that solves your problem

Word press Not Displaying Theme

Internal Server Error
The server encountered an internal error or mis configuration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
You can increase memory limit in 3 ways,
Edit your wp-config.php file
define('WP_MEMORY_LIMIT', '256M'); // if this is not in your wp-config file.
Edit your PHP.ini file
If you have access to your PHP.ini file, change the line in PHP.ini
memory_limit = 256M ; Maximum amount of memory a script may consume (64MB) //If your line shows 64M try 256M:
Edit your .htaccess file
If you don’t have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 256M
Hope this will help you.

Error: Internal Server Error (500) How to resolve this issue?

I will install theme and plugins successfully. When i will click on import demo data button after activate plugins, i get an error. Error: Internal Server Error (500) How to resolve this issue?
Note: I have LAMP Centos 7 Linux Server with 1GB RAM, 25GB Storage
Follow these steps to help in troubleshooting Internal Server Error (500) error:
First of all, Go FTP into your website
Open the file named wp-config.php on the root.
Find the line where you see define('WP_DEBUG', false);
Change false to true and save the file
And now you refresh the page you were getting an error on you should now see more descriptive error messages which will help in troubleshooting.
Create a new file in your /wp-admin/ folder and name it php.ini
Add these to the file :
memory_limit = 256M
always_populate_raw_post_data = -1
max_execution_time = 180
upload_max_filesize = 32M
post_max_size = 32M
Save it. This worked for me :)

What are the steps to move a MediaWiki website?

I am trying to move MediaWiki websites from Windows Server 2003 (IIS 6) to Windows Server 2008 R2 (IIS 7.5). I installed the same version of MediaWiki to the destination server in order to avoid conflict. I dumped, move and restore the MySQL database; zip, move and restore the MediaWiki files which includes the images, LocalSettings.php files for each MediaWiki website.
I can't browse the websites now, I believe I need to do something else but I am not sure. I am totally new to MediaWiki. Any help appreciated.
Thanks in advance.
$wiki_name = substr($_SERVER["REQUEST_URI"], 1, strpos($_SERVER["REQUEST_URI"], "/", 1) - 1);
$wgScriptPath = "/${wiki_name}";
$wgLogo = "images_${wiki_name}/${wiki_name}_logo.gif";
$wgUploadPath = "$wgScriptPath/images_${wiki_name}";
$wgUploadDirectory = "$IP/images_${wiki_name}";
require_once("LocalSettings.${wiki_name}.php");
unset($wiki_name);
LocalSettings.php has above section which has a purpose of using multiple mediawiki websites. And each LocalSettings.website.php files have section below:
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "database";
$wgDBuser = "user";
$wgDBpassword = "password";
in order to identify which database is used by each website.
This is the picture I got when I browsed the MediaWiki wiki through IIS.
And from server log I got the following:
#Date: 2014-10-06 19:42:17
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2014-10-06 19:42:17 ::1 GET /mediawiki - 80 - ::1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;+Trident/4.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET4.0C;+.NET4.0E) 301 0 0 265
2014-10-06 19:42:17 ::1 GET /mediawiki/ - 80 - ::1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;+Trident/4.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET4.0C;+.NET4.0E) 200 0 0 78
Which version do you use? AdminSettings.php was removed in MW 1.16, so you should consider to upgrading your wiki, this as a side note :)
You said, you have installed a new version of MediaWiki? Are there all files on your server? (Check the list from github e.g. https://github.com/wikimedia/mediawiki-core/tree/REL1_16).
Best!
The problem was about IIS declaration of virtual directory. And additionally needed to add index.asp and index.php files as default document through IIS.
Cheers!

Editing php.ini to allow certain features

Okay, so I've been testing and building a website on my computer through localhost. Everything works fine on my computer! I wanted to then upload it to my godaddy hosting account. Then I get an error. I am using json_decode as an argument for one of for each loops in my php. When I'm running my site through a hosting provider it tells me there is an invalid argument in the foreach() loop on like 43. So, I knew it had to do with my php.ini file, so I copied the one from my computer and pasted it in the php.ini file on godaddy, for my site. Then the foreach() loop worked! But, then all kinds of hell broke loose. Session problems and such. So, my question is, what do I need to add to make json_decode work?
Thanks
Here is my php.ini file with the hosting provider:
register_globals = off
allow_url_fopen = off
expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
extension_dir = ./
extension=json.so
upload_tmp_dir = /tmp
precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
; Only uncomment zend optimizer lines if your application requires Zend Optimizer
support
;[Zend]
;zend_optimizer.optimization_level=15
;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3
;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/ZendExtensionManager.so
;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/ZendExtensionManager_TS.so
; -- Be very careful to not to disable a function which might be needed!
; -- Uncomment the following lines to increase the security of your PHP site.
;disable_functions = "highlight_file,ini_alter,ini_restore,openlog,passthru,
; phpinfo, exec, system, dl, fsockopen, set_time_limit,
;
You cant just replace the php.ini file because it has paths hard coded.
For example, with your session error, most likely the setting session.save_path is referencing a directory that doesn't exist or incorrect permissions.
Can you post the line of code that was on line 43? I am guessing that your local php.ini doesn't display the error whereas the godaddy config does.