我正在尝试使用以下代码将文件上传到 rackspace 云文件:
上传.html
<form action="upload.php" enctype="multipart/form-data" method="POST">
File:
<input name="upload" type="file" />
<input name="submit" type="submit" value="Upload To Rackspace!" />
</form>
上传.php
<?php
// include the API
require('cloudfiles.php');
// cloud info
$username = ""; // username
$key = ""; // api key
// Connect to Rackspace
$auth = new CF_Authentication($username, $key);
$auth->authenticate();
$conn = new CF_Connection($auth);
// Get the container we want to use
$container = $conn->get_container('resumetune');
// store file information
$localfile = $_FILES['upload']['tmp_name'];
$filename = $_FILES['upload']['name'];
// upload file to Rackspace
$object = $container->create_object($filename);
$object->load_from_filename($localfile);
?>
现在我得到了令人发指的错误:
致命错误:在 C:\xampp\htdocs\rackspace\cloudfiles.php:1645 堆栈跟踪:#0 C:\xampp\htdocs\rackspace\cloudfiles.php 中未捕获的异常“BadContentTypeException”和消息“未设置所需的内容类型” (1962): CF_Object->_guess_content_type('C:\xampp\tmp\ph...') #1 C:\xampp\htdocs\rackspace\upload.php(24): CF_Object->load_from_filename('C:\ xampp\tmp\ph...') #2 {main} 在第 1645 行的 C:\xampp\htdocs\rackspace\cloudfiles.php 中抛出
那么有人对此有任何想法吗?提前致谢。