zip extension, small hint
In one of my projects, importing various data in CSV format is widely used. Once upon a time there was little data and everyone was happy to directly download one or two not too large files. Over time, data became more, the size of imported files and their number increased. It was decided to upload files in a ZIP archive: we save traffic + we have only one upload instead of several.
To work with the archive, I used the zip extension . I will not describe what is happening in this extension here, it is described in sufficient detail in the documentation.
I will tell only about one feature that has been useful to me. When importing a file that the user uploads in the form, the ZIP archive on the server alone is useless, and you also need to unpack it too: then you still have to delete it. The ZipArchive-> getStream () method comes to the rescue . We get the file-handler with its help and can safely feed it, say, in fgetcsv .
UPDProbably not completely understood. I need data from those CSV files that are in the ZIP. And I need this data in the database, and not in the TSSVs themselves, and even less so in the archive. That is, I import data from TSSVshek into the database. So I take a tempered temporary file ($ _FILES ['userfile'] ['tmp_name']). And without directly unpacking it, I import all the TsSVshki contained in it into the database. After that, PHP will take care of deleting the archive, which is no longer needed.
UPD From the Adelf habrayuzer : in some cases (not mine), the fact that $ _FILES ['userfile'] ['tmp_name'] may not be available due to open_basedir
I hope this information is useful to someone.
To work with the archive, I used the zip extension . I will not describe what is happening in this extension here, it is described in sufficient detail in the documentation.
I will tell only about one feature that has been useful to me. When importing a file that the user uploads in the form, the ZIP archive on the server alone is useless, and you also need to unpack it too: then you still have to delete it. The ZipArchive-> getStream () method comes to the rescue . We get the file-handler with its help and can safely feed it, say, in fgetcsv .
UPDProbably not completely understood. I need data from those CSV files that are in the ZIP. And I need this data in the database, and not in the TSSVs themselves, and even less so in the archive. That is, I import data from TSSVshek into the database. So I take a tempered temporary file ($ _FILES ['userfile'] ['tmp_name']). And without directly unpacking it, I import all the TsSVshki contained in it into the database. After that, PHP will take care of deleting the archive, which is no longer needed.
UPD From the Adelf habrayuzer : in some cases (not mine), the fact that $ _FILES ['userfile'] ['tmp_name'] may not be available due to open_basedir
I hope this information is useful to someone.