How to upload files ".zip" with php?

1

I use this library to upload images: piramideUploader . Upload the images without problem, the problem is when I try to upload a file ".zip".

My PHP is as follows:

if(isset($_FILES['uploads'])){
    $piramideUploader = new PiramideUploader();
    $upload = $piramideUploader->upload(
        'image', 
        "uploads", 
        "uploads", 
        array("image/jpeg","image/png","image/gif")
    );
    $file = $piramideUploader->getInfoFile();
    $file_name = $file['complete_name'];
    if(isset($upload) && $upload["uploaded"] == false){
        $result = array(
            'status'    => 'error',
            'code'      => 404,
            'message'   => 'El archivo no ha podido subirse'
        );
    }else{
        $result = array(
            'status'    => 'success',
            'code'      => 200,
            'message'   => 'El archivo se ha subido',
            'filename'  => $file_name
        );
    }
}

Try changing line 7: This:

array("image/jpeg","image/png","image/gif")

For this

array("*")

To try to admit all files, if that is the problem.

    
asked by Pablo Contreras 11.10.2018 в 18:45
source

1 answer

1

In your array add the following values 'application/zip', 'application/x-zip-compressed' , following your example with this you would be indicating that it also allows you to upload files type .zip .

I hope it serves you.

    
answered by 11.10.2018 / 19:55
source