简体   繁体   English

如何使用php webservice将图像上传到Amazon S3?

[英]How to upload an image to Amazon S3 using php webservice?

I am uploading an image to amazon S3 using php through webservice but it shows the following error: 我正在通过Web服务使用php将图像上传到Amazon S3,但显示以下错误:

failed to open stream: No such file or directory in and Failed opening required 'Zend/Service/Amazon/Abstract.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/jltcnyc1/public_html/mydb/S3.php 无法打开流:在中没有此类文件或目录,并且无法在以下位置中打开“ Zend / Service / Amazon / Abstract.php”(include_path = ..:/ usr / lib / php:/ usr / local / lib / php') /home/jltcnyc1/public_html/mydb/S3.php

require_once 'S3.php';
$s3 = new Zend_Service_Amazon_S3(secret_id,key);
$s3->createBucket("photos");
$file=basename($_FILES['file']['name']);
$s3->putObject("photos/", "file");
echo $s3->getObject("photos");

The file details are inserted into my db ok, but not to my S3. 文件详细信息插入到我的数据库中,但没有插入到我的S3中。

You have a path error and your 'Zend/Service/Amazon/Abstract.php' file is not being located. 您遇到路径错误,未找到“ Zend / Service / Amazon / Abstract.php”文件。

In your S3.php file, you need to include the appropriate path location for 'Zend/Service/Amazon/Abstract.php' from your server root. 在您的S3.php文件中,您需要从服务器根目录包括'Zend / Service / Amazon / Abstract.php'的适当路径位置。

If Abstract.php is in your server root that code looks like this: 如果Abstract.php在您的服务器根目录中,则代码如下所示:

require_once 'Abstract.php';

Alternatively, if your S3.php is not in your server root, you can fix your require_once in your code above like this: 或者,如果您的S3.php不在服务器根目录中,则可以像上面这样在上面的代码中修复require_once

require_once 'path_to_zend/S3.php';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM