Home Backend Development PHP Tutorial PHP automatically saves pictures when publishing articles_PHP tutorial

PHP automatically saves pictures when publishing articles_PHP tutorial

Jul 13, 2016 am 10:59 AM
array g img php keep publish an article picture accomplish hour automatic

<?php

$img_array = array();

$content1 = stripslashes($content1);

if (get_magic_quotes_gpc()) $content1 = stripslashes($content1);

//echo $content1;

preg_match_all("/(src│SRC)="(http://(. ).(gif│jpg│jpeg│bmp│png))/isU",$content1,$img_array);

$img_array = array_unique(dhtmlspecialchars($img_array[2]));

set_time_limit(0);

foreach ($img_array as $key => $value) {

$get_file = file_get_contents($value);

$filetime = time();

$filepath = "../uploadfile/".date("Y",$filetime)."/".date("m",$filetime)."/";

!is_dir($filepath) ? mkdirs($filepath) : null;

$filename = date("YmdHis",$filetime).random(1).'.'.substr($value,-3,3);

$fp = @fopen($filepath.$filename,"w");

@fwrite($fp,$get_file);

fclose($fp);

$content1 = preg_replace("/".addcslashes($value,"/")."/isU", "/uploadfile/".date("Y",$filetime)."/".date("m",$filetime)."/".$filename, $content1);

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631969.htmlTechArticle?php $img_array = array(); $content1 = stripslashes($content1); if (get_magic_quotes_gpc()) $content1 = stripslashes($content1); //echo $content1; preg_match_all(/(src│SRC)=(http...
Statement of this Website
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

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

BitMEX exchange withdrawal rules and advantages and disadvantages BitMEX exchange withdrawal rules and advantages and disadvantages Feb 21, 2025 pm 10:48 PM

BitMEX exchange withdrawal rules and advantages and disadvantages

gate official website entrance gate exchange official website gate official website entrance gate exchange official website Feb 19, 2025 pm 03:03 PM

gate official website entrance gate exchange official website

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

The latest top ten digital currency trading app rankings in 2025 The latest top ten digital currency trading app rankings in 2025 Feb 27, 2025 pm 06:24 PM

The latest top ten digital currency trading app rankings in 2025

The latest ranking list of the top ten formal virtual currency trading platforms in 2025 The latest ranking list of the top ten formal virtual currency trading platforms in 2025 Mar 05, 2025 pm 08:21 PM

The latest ranking list of the top ten formal virtual currency trading platforms in 2025

How to trade in TREZOR and what to note How to trade in TREZOR and what to note Feb 21, 2025 pm 10:30 PM

How to trade in TREZOR and what to note

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

PHP Program to Count Vowels in a String

See all articles