草庐IT

image_file

全部标签

PHP : add write permission to file after move_uploaded_file()

用PHP上传图像后,我想使图像文件可写,以便为其添加水印。以下是我使用的代码:if(isset($_FILES['file_poster']['tmp_name'])&&$_FILES['file_poster']['tmp_name']!=''){$random_filename=substr(md5(time()),0,9);$ext='.jpg';if(strpos(strtolower($_FILES['file_poster']['name']),'.png')>-1){$ext='.png';}move_uploaded_file($_FILES['file_poster'

PHP- file_get_contents 无法打开流 : Connection refused

我正在使用以下API通过IP获取国家/地区代码http://api.hostip.info/country.php?ip='.$IP示例:在本地主机$IP='202.71.158.30';//passtheipasaparameterforfollowURLitwillreturnthecountry$country_code=file_get_contents('http://api.hostip.info/country.php?ip='.$IP);它在这里工作正常并显示国家代码。但它在服务器上显示错误例子:$IP=$_SERVER['REMOTE_ADDR'];$country_

php - 在 view-file.blade.php 中找不到类 ' Form'

我正在尝试在我的View文件中呈现一个文本输入字段。我不断收到此错误:“在view-file.blade.php中找不到类‘表单’”模板:@extends('layouts.app')@section('content')New{{Form::open()}}{{ Form::text('my-name')}}{{Form::close()}}@endsectionComposer.json"require":{"php":">=7.0.0","fideloper/proxy":"~3.3","laravel/framework":"5.5.*","laravel/tinker":"~

php - 将 basename 函数与 $_FILES ['userFile' ] ['name' ] 一起使用不是多余的吗?

根据thePOSTmethoduploadssection的thePHPManual,$_FILES['userfile']['name']是客户端机器上文件的原始名称。该部分中的示例#2使用basename使用$_FILES['userfile']['name']的函数如下所示:$uploaddir='/var/www/uploads/';$uploadfile=$uploaddir.basename($_FILES['userfile']['name']);我在本地主机(Apache2.2.14、PHP5.3.1、WindowsXP)上做了一些实验,发现以下两行是等价的:$_FIL

php - 带有 __LINE__ __FILE__etc 的标准 PHP 错误函数?

所以,而不是很多if(odbc_exec($sql)){}else{myErrorHandlingFunction();}我把它包装在一个函数里functionmyOdbxExec($sql){if(odbc_exec($sql)){}else{myErrorHandlingFunction();}}但是我希望myErrorHandlingFunction()报告__LINE____FILE__等看起来我必须将这些信息传递给辅助函数的每次调用,例如myOdbxExec($sql,__FILE__,__LINE__)这让我的代码看起来很乱。functionmyErrorHandlingF

php - 使用 fwrite() 还是 move_uploaded_file() 更好?

这更像是一个编码标准问题。如果我可以称其为在文件上传处理程序脚本中使用它“更好”,那是哪一个?我知道fwrite()及其附带的读写方法可以分块进行,但使用move_uploaded_file()是更优雅和更短的代码。谢谢 最佳答案 使用move_uploaded_file()。它会进行额外的检查以确保用户不会从事任何有趣的业务。此外,使用fread()和fwrite()复制文件,而不是移动,这是一个比仅仅移动它(基本上只是更改它的名称,假设源和目标位于同一分区上)的成本要高几个数量级。

php - file_get_contents 在生产服务器上不工作,在本地很好

我有一个从远程服务器获取图像的PHP脚本,这样我就可以使用HTML5canvasAPI对其进行操作。getMessage();}}elsedie('Unknownrequest');?>一个典型的请求是这样的:fetch_image.php?url=http://example.com/images/image.png在我的本地服务器上一切正常,但生产服务器给我这个错误:NetworkError:500InternalServerError.错误日志记录了这条消息:PHPWarning:Cannotmodifyheaderinformation-headersalreadysent.我

php - move_uploaded_file 无法打开流和权限被拒绝错误

我正在尝试上传文件,但我的浏览器出现以下错误:Warningmove_uploaded_file(public/upload/udesignwptheme138.zip)[function.move-uploaded-file]:failedtoopenstream:Permissiondeniedin/home/monivbr/public_html/classes/system/Util.phponline1803Warning:move_uploaded_file()[function.move-uploaded-file]:Unabletomove'/tmp/phpJtBlbi

PHP - 字符串中带有变量的 file_get_contents()?

我正在尝试在收到此订单时通过PHPMailer将订单通过电子邮件发送给客户。我试过这样做:$email_page=file_get_contents("email_order_html.php?order=$order_id");我想以字符串形式获取此页面的内容,以便我可以使用PHPMailer发送此内容,但此函数不会执行该页面,因为其中包含变量$order_id,我该如何解决此问题? 最佳答案 您只能在将file_get_contents与UrlAwareStreamWrapper一起使用时添加查询参数,例如它适用于http://

php - 即使 file_exists() 声明文件存在,require() 也会失败

这是我的代码:if(file_exists('config.php')){require('config.php');//Thisisline38}以某种方式产生错误:Warning:require(config.php)[function.require]:failedtoopenstream:Nosuchfileordirectoryin/path/name/file.phponline38这怎么可能?更新:以下确实有效:if(file_exists(getcwd().'/config.php')){require(getcwd().'/config.php');}