mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
fix attachment upload location
This commit is contained in:
@@ -235,11 +235,12 @@ if ($Attach->enable_attachment())
|
|||||||
if ($hasthumb) {
|
if ($hasthumb) {
|
||||||
$url .= ".thumb.jpg";
|
$url .= ".thumb.jpg";
|
||||||
}
|
}
|
||||||
|
$location = $db_file_location.".".$ext;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$driver = \Nexus\Attachment\Storage::getDriver();
|
$driver = \Nexus\Attachment\Storage::getDriver();
|
||||||
$location = $driver->uploadGetLocation($file["tmp_name"], $file['name']);
|
$location = $driver->uploadGetLocation($file["tmp_name"], $file['name']);
|
||||||
$db_file_location = substr($location, 0, -1*strlen($ext)-1);
|
do_log("location: $location");
|
||||||
$url = $driver->getImageUrl($location);
|
$url = $driver->getImageUrl($location);
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
do_log("upload failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error');
|
do_log("upload failed: " . $exception->getMessage() . $exception->getTraceAsString(), 'error');
|
||||||
@@ -248,8 +249,8 @@ if ($Attach->enable_attachment())
|
|||||||
}
|
}
|
||||||
if (!$warning) //insert into database and add code to editor
|
if (!$warning) //insert into database and add code to editor
|
||||||
{
|
{
|
||||||
$dlkey = md5($db_file_location.".".$ext);
|
$dlkey = md5($location . microtime(true));
|
||||||
sql_query("INSERT INTO attachments (userid, width, added, filename, filetype, filesize, location, dlkey, isimage, thumb, driver) VALUES (".$CURUSER['id'].", ".$width.", ".sqlesc(date("Y-m-d H:i:s")).", ".sqlesc($origfilename).", ".sqlesc($filetype).", ".$filesize.", ".sqlesc($db_file_location.".".$ext).", ".sqlesc($dlkey).", ".($isimage ? 1 : 0).", ".($hasthumb ? 1 : 0). "," .sqlesc($storageDriver) . ")") or sqlerr(__FILE__, __LINE__);
|
sql_query("INSERT INTO attachments (userid, width, added, filename, filetype, filesize, location, dlkey, isimage, thumb, driver) VALUES (".$CURUSER['id'].", ".$width.", ".sqlesc(date("Y-m-d H:i:s")).", ".sqlesc($origfilename).", ".sqlesc($filetype).", ".$filesize.", ".sqlesc($location).", ".sqlesc($dlkey).", ".($isimage ? 1 : 0).", ".($hasthumb ? 1 : 0). "," .sqlesc($storageDriver) . ")") or sqlerr(__FILE__, __LINE__);
|
||||||
$count_left--;
|
$count_left--;
|
||||||
if (!empty($_REQUEST['callback_func']) && preg_match('/^preview_custom_field_image_\d+$/', $_REQUEST['callback_func'])) {
|
if (!empty($_REQUEST['callback_func']) && preg_match('/^preview_custom_field_image_\d+$/', $_REQUEST['callback_func'])) {
|
||||||
echo sprintf('<script type="text/javascript">parent.%s("%s", "%s")</script>', $_REQUEST['callback_func'], $dlkey, $url);
|
echo sprintf('<script type="text/javascript">parent.%s("%s", "%s")</script>', $_REQUEST['callback_func'], $dlkey, $url);
|
||||||
|
|||||||
Reference in New Issue
Block a user