php類比post請求傳送檔案代碼

由於項目需要,需要本機伺服器接收資料後,再將資料轉寄到另外一台伺服器上,故要用到類比post請求發送資料,當然資料中也包含檔案流。 curl是php比較常用的方式之一,一般代碼如下: $params1 = "test"; $params2 = "@".$absolute_path;//如果是檔案 則參數為"@"+絕對路徑 $post_data = array( 'params1' => $params1,

PHP強制性檔案下載

如果你需要下載特定的檔案而不用另開新視窗,下面的程式碼片段可以協助你。 function force_download($file) { $dir = "../log/exports/"; if ((isset($file))&&(file_exists($dir.$file))) { header("Content-type: application/force-download");

使用使用 imagebrick將pdf轉成圖片

$pdf_file = './pdf/demo.pdf';$save_to = './jpg/demo.jpg'; //make sure that apache has permissions to write in this folder! (common problem)//execute ImageMagick command 'convert' and convert PDF to JPG with applied settingsexec('convert "'.$

PHP一個簡單的快速排序

通過不斷的定位基準數的位置來實現快速排序 /** * Created by PhpStorm. * User: saint * Date: 15/8/5 * Time: 上午11:49 */class Demo{ public $a = array(3, 6, 9, 2, 4, 7, 1, 5, 8, 0); public function qsort($left, $right) { if($left > $right) {

PHP 片段即時壓縮 zip 檔案

使用下面的 PHP 片段可以即時壓縮 zip 檔案 function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; }

PHP數字運算驗證碼

getValidate(100,30); function getValidate($w,$h){ $img = imagecreate($w,$h); $gray = imagecolorallocate($img,255,255,255); $black = imagecolorallocate($img,rand(0,200),rand(0,200),rand(0,200));

使用 mandrill 發送郵件的PHP代碼

Mandrill 是一款強大的 SMTP 提供器。開發人員傾向於使用一個第三方 SMTP provider 來擷取更好的收件交付。 下面的函數中,你需要把 “Mandrill.php” 放在同一個檔案夾,作為 PHP 檔案,這樣就可以使用TA來發送郵件。 function send_email($to_email,$subject,$message1){require_once 'Mandrill.php';$apikey = 'XXXXXXXXXX'; //specify your

使用IP判斷訪問使用者是在哪個城市的PHP代碼

function detect_city($ip) { $default = 'UNKNOWN'; $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; $url =

php壓縮CSS檔案

一次壓縮多個CSS檔案 header('Content-type: text/css');ob_start("compress");function compress($buffer) {/* remove comments */$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);/* remove tabs, spaces, newlines, etc. */$buffer =

PHP通過ffmpeg給視頻增加字幕顯示

$dir = './'; // set to current folderif ($handle = opendir($dir)) { while(false!== ($file = readdir($handle))) { if ( is_file($dir.$file) ){ if (preg_match("'\.(avi)$'", $file) ){ $sub_file = str_ireplace(".avi", ".srt", $dir.$file); $idx_file = str_

PHPExcel 資料匯出執行個體

一、getdata.php namespace Webadmin\Model;use ExtendSpace\Excel; …… 略 …… // 取出資料 $dataBillArr = $this->get_list_bysql($sql); // 替換資料中的 0 、1 為 是、否 // PHPExcel 有內建的方法處理,但是得到的是 TRUE/FALSE,這裡自己處理吧

PHP敏感字過濾代碼

$f = file('words.txt');$words = array();foreach ($f as $w) { $words[] = preg_quote(trim($w), '/');}$text = file_get_contents('text.txt'); $start = microtime(true);$reg = '/' . implode('|', $words) . '/S'; preg_match_all($reg, $text, $m); $result =

PHP 列出 MySQL 中所有的資料庫

define( 'NL', "\n" );define( 'TB', ' ' );// connecting to MySQL.$conn = @mysql_connect( 'localhost', 'username', 'password' ) or die( mysql_errno().': '.mysql_error().NL );// attempt to get a list of MySQL databases// already set up in my

給圖片添加浮水印的PHP類

支援文字浮水印、圖片浮水印支援浮水印的位置隨機或固定(九宮格)浮水印透明度設定(圖片浮水印和文字浮水印都支援)文字 浮水印的字型、顏色、大小設定圖片浮水印的背景透明 /** * 加浮水印類,支援文字圖片浮水印的透明度設定、浮水印圖片背景透明。 * 日期:2011-09-27 * 作者:www.itwhy.org * 使用: * $obj = new WaterMask($imgFileName); //執行個體化對象 * $obj->$waterType =

PHP下載/採集遠程圖片到本地

/** * 下載遠程圖片到本地 * * @param string $url 遠程檔案地址 * @param string $filename 儲存後的檔案名稱(為空白時則為隨機產生的檔案名稱,否則為原檔案名稱) * @param array $fileType 允許的檔案類型 * @param string $dirName 檔案儲存的路徑(路徑其餘部分根據時間系統自動產生) * @param int $type 遠程擷取檔案的方式 * @return json 返迴文件名、檔案的儲存路徑 *

PHP遍曆目錄的代碼

PHP目錄的遍曆 //php目錄的遍曆function showDetail($dirname){$ds = opendir($dirname);while($file = readdir($ds)){$path = $dirname."/".$file;if($file != "." && $file != ".."){ //這裡是個坑if(is_dir($path)){showDetail($path);

PHP 實現的網頁代理

if ( !isset($_REQUEST["url"]) ) exit; $u = $_REQUEST["url"]; if (substr($u, -0, 7) != "http://") exit; echo file_get_contents( $u );/* function getPage($url, $referer, $timeout, $header=true){ if(!isset($timeout)) $timeout=30;

PHP根據當天的年月日擷取當前周的周日的年月日

//擷取年月日對應的最近的周天的到期日 可能會 跨年 跨月 跨周function GetClearWeek() { $year_month_day_over = array(); $year = date('Y'); //四位 的年份 $month = date('n'); //1 到 12 $day_of_month = date('j');//1-31 月份中的第幾天 $day_of_week = date('N'); //1-7 周中的第幾天

PHP對圖片進行浮水印添加以及產生縮率圖

1 給圖片進行浮水印添加 2產生一個新的縮率圖 class Image{ //浮水印配置項 private $waterOn; private $waterImg; private $waterPos; private $waterPct; private $waterText; private $waterFont; private $waterTextSize;

PHP利用GD庫實現一個簡單的驗證碼

$img=imagecreatetruecolor(100, 40);$red=imagecolorallocate($img, 255, 0, 0);$green=imagecolorallocate($img, 0, 255, 0);$blue=imagecolorallocate($img, 0, 0, 255);$white=imagecolorallocate($img, 255, 255, 255);$black=imagecolorallocate($img, 0, 0, 0);/

總頁數: 5203 1 .... 1694 1695 1696 1697 1698 .... 5203 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.