當前位置:首頁 » 文件傳輸 » 上傳zip文件並解壓
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

上傳zip文件並解壓

發布時間: 2022-04-24 22:35:41

Ⅰ asp.net用FileUpload控制項上傳.zip的壓縮包到伺服器之後自動解壓到指定的文件夾下怎麼實現

分為兩步:
1.
文件上傳到伺服器某個目錄,這一步比較簡單;
2.
將文件進行解壓到某個目錄,這一步需要用到一個Ionic.Zip.dll。

Ⅱ 怎麼用php寫一個表單上傳zip格式的壓縮包並解壓到根目錄的指定目錄中

<?php
if($_FILES["file"]["error"]>0){
echo"<script>console.log('ReturnCode:".$_FILES["file"]["error"]."');</script>";
}
else{
if(!file_exists("upload/".$_FILES["file"]["name"])){
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/".$_FILES["file"]["name"]);
echo"Storedin:"."upload/".$_FILES["file"]["name"];
system('zip解壓縮命令');
}
else{
system('zip解壓縮命令');
}
}
?>

因為php即使拓展了zip庫,也不能夠實現解壓縮,而且拓展zip庫會要更改php.ini,所以推介下載7z的命令行版本,用系統命令解決。╮( ̄▽ ̄"")╭

Ⅲ php 怎樣上傳壓縮包並解壓到目錄

1.查找一般的php上傳類都可以上傳 zip 文件的。 (記得設置好上傳文件格式就好)

2.確認你的php擴展中 包含有 php_zip 這個擴展。
然後找 zip 的相關函數方法吧。 php手冊中去看。

Ⅳ PHP源碼上傳zip文件在服務端自動解壓並遞增生成類似20150109文件名的文件夾

是先生成日期文件夾吧,然後再把當天上傳的zip文件放到放到該文件夾中,再解壓,刪除源zip文件。。。

Ⅳ 手機如何打壓縮包和解壓

  • 第一步,找到手機中的【文件管理】圖標,可以通過這個找到手機上的壓縮文件,如下圖所示:

Ⅵ java解析xml 我現在所要做的是將一個zip文件上傳到伺服器,然後解壓,解壓後文件為有txt,xml

上傳有控制項直接就可以用,解壓要在程序里做 然後將txt和xml放在伺服器目錄下,至於文件的判斷你判斷後綴名就行了。

讓上傳後解壓要調用系統的api 估計你調不到

Ⅶ java如何解壓頁面上傳到伺服器的zip文件

直接通過工具類進行解壓或者壓縮文件即可。

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

/**
*
* @author gdb
*/
public class ZipUtilAll {
public static final int DEFAULT_BUFSIZE = 1024 * 16;

/**
* 解壓Zip文件
*
* @param srcZipFile
* @param destDir
* @throws IOException
*/
public static void unZip(File srcZipFile, String destDir) throws IOException
{
ZipFile zipFile = new ZipFile(srcZipFile);
unZip(zipFile, destDir);
}

/**
* 解壓Zip文件
*
* @param srcZipFile
* @param destDir
* @throws IOException
*/
public static void unZip(String srcZipFile, String destDir) throws IOException
{
ZipFile zipFile = new ZipFile(srcZipFile);
unZip(zipFile, destDir);
}

/**
* 解壓Zip文件
*
* @param zipFile
* @param destDir
* @throws IOException
*/
public static void unZip(ZipFile zipFile, String destDir) throws IOException
{
Enumeration<? extends ZipEntry> entryEnum = zipFile.entries();
ZipEntry entry = null;
while (entryEnum.hasMoreElements()) {
entry = entryEnum.nextElement();
File destFile = new File(destDir + entry.getName());
if (entry.isDirectory()) {
destFile.mkdirs();
}
else {
destFile.getParentFile().mkdirs();
InputStream eis = zipFile.getInputStream(entry);
System.out.println(eis.read());
write(eis, destFile);
}
}
}

/**
* 將輸入流中的數據寫到指定文件
*
* @param inputStream
* @param destFile
*/
public static void write(InputStream inputStream, File destFile) throws IOException
{
BufferedInputStream bufIs = null;
BufferedOutputStream bufOs = null;
try {
bufIs = new BufferedInputStream(inputStream);
bufOs = new BufferedOutputStream(new FileOutputStream(destFile));
byte[] buf = new byte[DEFAULT_BUFSIZE];
int len = 0;
while ((len = bufIs.read(buf, 0, buf.length)) > 0) {
bufOs.write(buf, 0, len);
}
} catch (IOException ex) {
throw ex;
} finally {
close(bufOs, bufIs);
}
}

/**
* 安全關閉多個流
*
* @param streams
*/
public static void close(Closeable... streams)
{
try {
for (Closeable s : streams) {
if (s != null)
s.close();
}
} catch (IOException ioe) {
ioe.printStackTrace(System.err);
}
}

/**
* @param args
* @throws java.lang.Exception
*/
public static void main(String[] args) throws Exception
{
// unZip(new File(ZipDemo.class.getResource("D:/123/HKRT-B2B.zip").toURI()), "D:/123/");
unZip("D:/123/123.zip", "D:/123/");
// new File();
}
}