首页 > 编程知识 正文

php里面put(php里面有面向对象的编程思想)

时间:2023-11-30 11:44:49 阅读:310585 作者:JYDO

本文目录一览:

  • 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会去检查配置文件是否正确,如果有配置错误,

这里会报错,可以根据错误信息去排查!

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。