fix png upload

This commit is contained in:
themohooks 2024-07-05 12:44:31 +03:00
parent f6aa6bcdad
commit 1870a8c710
2 changed files with 11 additions and 2 deletions

View file

@ -20,6 +20,7 @@ class Upload
DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :place, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup'=>time())); DB::query('INSERT INTO photos VALUES (\'0\', :userid, :postbody, :photourl, :time, :timeup, :exif, 0, :place, :content)', array(':postbody' => $postbody, ':userid' => Auth::userid(), ':time' => mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']), ':content' => $content, ':photourl' => self::$photourl, ':exif' => $exif, ':place' => $_POST['place'], ':timeup'=>time()));
echo json_encode( echo json_encode(
array( array(
'id' => DB::query('SELECT id FROM photos ORDER BY id DESC LIMIT 1')[0]['id'],
'errorcode' => 0, 'errorcode' => 0,
'error' => 0 'error' => 0
) )
@ -30,7 +31,15 @@ class Upload
if ($_FILES['image']['error'] != 4) { if ($_FILES['image']['error'] != 4) {
$exif = new EXIF($_FILES['image']['tmp_name']); $exif = new EXIF($_FILES['image']['tmp_name']);
$exif = $exif->getData();
$upload = new UploadPhoto($_FILES['image'], 'cdn/img'); $upload = new UploadPhoto($_FILES['image'], 'cdn/img');
if ($exif === null) {
$exif = Json::return(
array(
'type' => 'none',
)
);
}
if ($upload->getType() !== null) { if ($upload->getType() !== null) {
$content = Json::return( $content = Json::return(
array( array(
@ -40,7 +49,7 @@ class Upload
) )
); );
self::$photourl = $upload->getSrc(); self::$photourl = $upload->getSrc();
self::create($_POST['descr'], $content, $exif->getData()); self::create($_POST['descr'], $content, $exif);
} }
} else { } else {
echo json_encode( echo json_encode(

View file

@ -724,7 +724,7 @@ return xhr;
ws.send(JSON.stringify(positionData));*/ ws.send(JSON.stringify(positionData));*/
setTimeout(function() { setTimeout(function() {
window.location.replace("/feed"); window.location.replace("/photo/"+jsonData.id);
scrollProgressBarWidth(0); scrollProgressBarWidth(0);
}, 1000); }, 1000);
} else if (jsonData.errorcode == "LIMITEXCEEDED") { } else if (jsonData.errorcode == "LIMITEXCEEDED") {