This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi, I'm trying to create a class CreateFile to create a .txt file.
And a class CreateZip, which achieves a .zip file through one or more paths ...
I can create the .txt files, but not .zip ...
You have ideas?
My code:
$file = new File;
$file->data = 'file_input.txt';//fopen('/file_input.txt', "x");//Input::file('file_input.zip');
$file->disk_name = $disk_name;
$file->file_name = 'file_input.txt';
$file->file_size = '2333';
$file->content_type = 'application/txt';
$file->is_public = true;
$file->save();
$fp = fopen($file->getLocalPath(), "w"); //fopen('/public/'.$path.$disk_name, "xw");
fwrite($fp, '1');
fwrite($fp, '23');
fclose($fp);
with $file can I create the file on the disk and DB system_files
and fopen and fwrite function bat in db content_type = inode/x-empty
, file_size = 0
If .txt change in .zip $file does not work completely
Ideas?
Help me
Sorry for my English, I'm Italian
Unfortunately, you cannot create an archive (or zip file) by just changing the extension. A zip file is completely different to a txt file (just look at it by opening both of them in a text-editor like Notepad, Sublime Text or Notepad++.
Since it's not that simple to create a class that handles zip archive (de)compression. I would recommend you head over to packagist and look for appropriate packages (like this for archive (de)compression). These packages are much more reliable, more widely used, and better tested.
1-3 of 3