Home  >  Article  >  WeChat Applet  >  Detailed explanation on uploading word, txt, Excel, PPT and other files to WeChat mini program

Detailed explanation on uploading word, txt, Excel, PPT and other files to WeChat mini program

jacklove
jackloveOriginal
2018-06-11 17:34:2812700browse

Currently, the mini program does not have an API that can implement this function, so I implement it here by using web-view;

Implementation process:

1. Configure the business domain name in the background of the mini program

2. Write an html on the server to implement the form upload file

3. The back-end php receives the file and saves it to a server folder, and saves the file name to the database for later retrieval

4. Create a page in the WeChat applet and use web-view to upload files;

Rendering:

Detailed implementation:

1. Configure the business domain name in the mini program background

Address: https://mp.weixin.qq.com/wxopen/appdatacount


2. Write an html on the server to implement the form upload file

index.html file




	
		
		
		Title
		
	

	
		


##3. The back-end php receives the file and saves it to a server folder, and saves the file name to the database for later retrieval using

up_file.php file:


 0)  
	  {  
	  echo "错误: " . $_FILES["file"]["error"] . "
"; } else { $dlog["name"]=$_FILES["file"]["name"]; $dlogs=$dlog; //echo urldecode(json_encode($dlogs)); $name =$_FILES["file"]["name"]; echo '上传成功!'; echo $name; //插入数据到数据库 $strsql = "insert into name (fileName) values('$name')"; //mysql_query() 函数执行一条 MySQL 查询。SELECT,SHOW,EXPLAIN 或 DESCRIBE 都需要用这个函数执行 $result = @mysql_query($strsql); // echo "文件名: " . $_FILES["file"]["name"] . "
"; // echo "类型: " . $_FILES["file"]["type"] . "
"; // echo "大小: " . ($_FILES["file"]["size"] / 1024) . " Kb
"; } if (file_exists("upload/" . $_FILES["file"]["name"])) { // echo $_FILES["file"]["name"] . " 文件已经存在. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); // echo "文件已经被存储到: " . "upload/" . $_FILES["file"]["name"]; } ?>

4. Create a WeChat applet page, which uses web-view to upload files;

web.wxml file


 

Note: The WeChat applet web-view tag is used as above, no redundant code is required.

This article explains in detail the content of WeChat applet uploading word, txt, Excel, PPT and other files. For more related content, please pay attention to the php Chinese website.

Related recommendations:

Introduction to bubbling, dichotomy insertion, quick sort algorithm

Explain how PHP supports breaking Related content of the file download class that you click on to resume the upload

How to filter the html tag attribute class through php

The above is the detailed content of Detailed explanation on uploading word, txt, Excel, PPT and other files to WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn