How to Unzip File and Move to PHP? - PowerPoint PPT Presentation

About This Presentation
Title:

How to Unzip File and Move to PHP?

Description:

This article is about how to unzip folder using command line code and move that files into the path you want. PHP provides exec command to execute command line functions. – PowerPoint PPT presentation

Number of Views:9
Slides: 10
Provided by: dynaaddison
Category:
Tags: how_to | file | move | php | programming | unzip

less

Transcript and Presenter's Notes

Title: How to Unzip File and Move to PHP?


1
How to Unzip File and Move to PHP?
  • PHP Programming Tutorial

2
To Unzip File and Move to Destination in PHP
3
To Unzip File and Move to Destination in PHP
  • Here, Here I comes with the quick article, this
    is small post but very effective.
  • This article is about how to unzip folder using
    command line code and move that files into the
    path you want.
  • PHP provides exec command to execute command line
    functions.
  • Here we will use that function to unzip files and
    which is very easy and one line code to

4
To Unzip File and Move to Destination in PHP
  • unzip a files.
  • Following line of code will unzip file and move
    it from source to destination folder.
  • exec("unzip src_folder -d ' . dest_folder .
    '/')

5
To Unzip File and Move to Destination in PHP
  • Next, You have to give permissions to the folders
    and files you unzipped.
  • So,Following code with change the permission of
    files and directories.
  • exec("find dest_folder -type d -exec chmod 0777
    ") // d is used for directory
  • exec("find dest_folder -type f -exec chmod 0777
    ")// f is used for files.

6
To Unzip File and Move to Destination in PHP
  • After, giving permission to files,you can
    copy/move it to the directory you want.
  • Lets see the code to move files.
  • files scandir(dest_folder) // Identify
    directories
  • foreach(files as file)
  • if (in_array(file, array(".", "..")))
  • continue

7
To Unzip File and Move to Destination in PHP
  • // If we copied this successfully, mark it for
    deletion
  • if (copy(dest_folder.file,
    new_dest_folder.file))
  • unlink_files dest_folder.file
  • // Delete all successfully-copied files
  • foreach (unlink_files as unlink_file)
  • unlink(unlink_file)

8
To Unzip File and Move to Destination in PHP
  • That it. You can use code and put your comment
    if any query.
  • Hope this tutorial on PHP programming helpful to
    you. As always, thanks for reading an article.
  • Dont Forget to Follow us on Twitter or Subscribe
    us to Get the Latest Updates.

9
Thank You Creative Devinfo_at_creativedev.in
Write a Comment
User Comments (0)
About PowerShow.com