本文目錄一覽:
- 1、PHP 怎麼使用put
- 2、php put方式怎麼接收文件,
- 3、關於PHP的ftp_put報錯
- 4、PHP裏面put_file_contents如何在指定文件夾里創建文件?
- 5、PHP如何獲取PUT和DELETE請求的參數
PHP 怎麼使用put
//接收上傳的文件
foreach($_FILES as $file)
{
$tempFileName = $file[‘tmp_name’];//上傳文件的臨時路徑
}
/把圖片移動到服務器制定路徑
$img = ‘/var/www/html/picture/test.jpg’;
move_uploaded_file($tempFileName, $img);
//縮放比例
$ratio = 0.5;
//修改尺寸 至於各個函數是幹嘛的,google一下吧
$imagedata = getimagesize($img);
$olgWidth = $imagedata[0];
$oldHeight = $imagedata[1];
$newWidth = $olgWidth * $ratio;
$newHeight = $oldHeight * $ratio;
$image = imagecreatefromjpeg($img);
$thumb = imagecreatetruecolor ($newWidth, $newHeight);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $newWidth, $newHeight, $olgWidth, $oldHeight);
imagejpeg($thumb, $img);
imagedestroy($thumb);
imagedestroy($image);
php put方式怎麼接收文件,
?php
function curlrequest($url,$data,$method=’post’){
$ch = curl_init(); //初始化CURL句柄
curl_setopt($ch, CURLOPT_URL, $url); //設置請求的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //設為TRUE把curl_exec()結果轉化為字串,而不是直接輸出
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //設置請求方式
curl_setopt($ch,CURLOPT_HTTPHEADER,array(“X-HTTP-Method-Override: $method”));//設置HTTP頭信息
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//設置提交的字符串
$document = curl_exec($ch);//執行預定義的CURL
if(!curl_errno($ch)){
$info = curl_getinfo($ch);
echo ‘Took ‘ . $info[‘total_time’] . ‘ seconds to send a request to ‘ . $info[‘url’];
} else {
echo ‘Curl error: ‘ . curl_error($ch);
}
curl_close($ch);
return $document;
}
$url = ”;
$data = “request from put method”;
$return = curlrequest($url, $data, ‘put’);
var_dump($return);exit;
?
2. [代碼][PHP]代碼
?php
$arguments = file_get_contents(‘php://input’);
print_r($arguments);
關於PHP的ftp_put報錯
$myftp-ftp_upload_mode=’FTP_BINARY’;
取消’引號
$myftp-ftp_upload_mode=FTP_BINARY;
PHP裏面put_file_contents如何在指定文件夾里創建文件?
先檢查那個文件夾你是否有寫權限;這個函數第一個參數是文件名,如果文件不存在會自動創建。
PHP如何獲取PUT和DELETE請求的參數
進入php源程序目錄中的ext目錄中,這裡存放着各個擴展模塊的源代碼,選擇你需要的模塊,比如curl模塊:cd curl
執行phpize生成編譯文件,phpize在PHP安裝目錄的bin目錄下
/usr/local/php5/bin/phpize
運行時,可能會報錯:Cannot find autoconf. Please check your autoconf installation and
the $PHP_AUTOCONF
environment variable is set correctly and then rerun this
script.,需要安裝autoconf:
yum install autoconf(RedHat或者CentOS)、apt-get install
autoconf(Ubuntu Linux)
/usr/local/php5/bin/php -v
執行這個命令時,php會去檢查配置文件是否正確,如果有配置錯誤,
這裡會報錯,可以根據錯誤信息去排查!
原創文章,作者:NYKZ8,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/128365.html