我上传从我自己的服务器上的文件,以soundcloud.com在PHP中使用的API文件:上传使用PHP
if (isset($mime)) {
$tmp_file = $tmp_path . $_FILES['file']['name'];
// Store the track temporary.
if (move_uploaded_file($_FILES['file']['tmp_name'], $tmp_file)) {
$post_data = array(
'track[title]' => stripslashes($_POST['title']),
'track[asset_data]' => realpath($tmp_file),
'track[sharing]' => 'private'
);
if ($response = $soundcloud->upload_track($post_data, $mime)) {
$response = new SimpleXMLElement($response);
$response = get_object_vars($response);
$message = 'Success! <a href="' . $response['permalink-url'] . '">Your track</a> has been uploaded!';
// Delete the temporary file.
unlink(realpath($tmp_file));
} else {
$message = 'Something went wrong while talking to SoundCloud, please try again.';
}
} else {
$message = 'Couldn\'t move file, make sure the temporary path is writable by the server.';
}
} else {
$message = 'SoundCloud support .mp3, .aiff, .wav, .flac, .aac, and .ogg files. Please select a different file.';
}
}
这是我的代码。临时路径是http://122.166.23.38/dev3/bids4less/funkeymusic/upload
并且它具有权限777(-rwxrwxrwx)。
但它显示:
无法移动文件,确保临时路径是由服务器写入。
如何解决此问题?
是你的服务器根目录下的临时目录? – Thariama 2010-06-24 11:39:08
no root-> funkeymusic-> upload – rajanikant 2010-06-24 11:54:01