Archive: file

 

Posts Tagged ‘file’


If you want to serve up text files for download (perhaps product feeds etc) then you might like this little snippet. Not only will it force the file to be downloaded but it allows you to specify a custom filename that it should be saved as. PLAIN TEXT PHP: if(isset($_GET['download_file'])){     header("Content-type: application/octet-stream");   [...]



 

If you are having an issue with Magento and the optional Merge CSS Files (beta) turned on and it not updating with recent CSS changes, you may appreciate this. Unlike other cached elements that are stored in var/cache, Magento stores the cached and minified CSS files in media/css If you simply delete the contents of [...]



 

If you are tearing your hair out trying to figure out why trying to run something is complaining that it doesn't exist when it clearly does, this is quite possibly your solution. The problem is most likely that you are trying to run a 32bit package on a 64bit system. The solution is easy enough, [...]



 

If you want to calculate the actual save path that Magento will use for an image file for example then you might find yourself scouring the source code for the specific method that does this. It's not the easiest to find, in fact its tucked away in the lib folder inside the Varien_File_Uploader class. The [...]



 

Linux has a great little utility called split, which can take a file and split it into chunks of whatever size you want, eg 100 line chunks. However, for CSV files etc, each chunk generally needs to have the header row in there. Unfortunately the split command doesn't have an option for that. However with [...]



 

This little PHP function will allow you to import a csv or tab etc delimited text file into a database table. Handy if you need it PLAIN TEXT PHP: function build_table_from_file($tablename, $filepath, $delim="\t") {     db_query("DROP TABLE IF EXISTS $tablename");     $fp=fopen($filepath, 'r');     $headers=false;     while($r=(($delim=='csv')?fgetcsv($fp):fgets($fp))) {       [...]