本文整理汇总了PHP中myContentStorage::getTempUploadHash方法的典型用法代码示例。如果您正苦于以下问题:PHP myContentStorage::getTempUploadHash方法的具体用法?PHP myContentStorage::getTempUploadHash怎么用?PHP myContentStorage::getTempUploadHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myContentStorage
的用法示例。
在下文中一共展示了myContentStorage::getTempUploadHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFile
public static function uploadFile($file_data, $id, $filename, $hash, $extra_id = null)
{
$realHash = myContentStorage::getTempUploadHash($filename, $id);
// TODO - what if there is an error while uploading ?
// filename is OK?
if ($realHash == $hash && $hash != "") {
//create the directory if doesn't exists (should have write permissons)
// if(!is_dir("./files")) mkdir("./files", 0755);
//move the uploaded file
$origFilename = $file_data['name'];
$parts = pathinfo($origFilename);
$extension = strtolower($parts['extension']);
$filename = $id . '_' . $filename;
// add the file extension after the "." character
$fullPath = myContentStorage::getFSUploadsPath() . $filename . ($extra_id ? "_" . $extra_id : "") . "." . $extension;
myContentStorage::fullMkdir($fullPath);
if (!move_uploaded_file($file_data['tmp_name'], $fullPath)) {
KalturaLog::log("Error while uploading [{$id}] [{$filename}] [{$hash}] [{$extra_id}] " . print_r($file_data, true) . "\n->[{$fullPath}]");
return false;
}
@chmod($fullPath, 0777);
return true;
}
return false;
}
示例2: getTempUploadUrlParams
/**
* This function returns the upload url paramters needed to securely upload a file.
* The resulting parameters are filename and hash.
* The filename is the given entity name (thumbnail, audio, etc...)
* The hash is generated using the myContentStorage::getTempUploadHash function.
* @param string $entityName = the entity object name
* @param int $kuser_id = the uploading kuser id
* @return string the url parameters string
*/
public static function getTempUploadUrlParams($entityName, $kuser_id, $user = NULL)
{
// TODO - i added this becuase it took me 3 hours to find this bug.
// it's clear that the module from which this is called should enforce logging in, but i added this extra defence - Eran ??
if ($kuser_id == NULL || strlen($kuser_id) == 0) {
throw new Exception("Should not be called when user is not logged in !");
}
$hash = myContentStorage::getTempUploadHash($entityName, $kuser_id, $user);
if ($hash != "") {
return "?id={$kuser_id}&filename={$entityName}&hash={$hash}";
}
return "";
}