简体   繁体   中英

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:

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

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.

You have a path error and your 'Zend/Service/Amazon/Abstract.php' file is not being located.

In your S3.php file, you need to include the appropriate path location for 'Zend/Service/Amazon/Abstract.php' from your server root.

If Abstract.php is in your server root that code looks like this:

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:

require_once 'path_to_zend/S3.php';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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