diff --git a/nginx.conf b/nginx.conf index f20905e..79ff553 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,6 +1,7 @@ server { listen 80; server_name localhost; + client_max_body_size 10M; # 1. Landing Page Utama location / { diff --git a/poverty-mapping/Dockerfile b/poverty-mapping/Dockerfile index 85523ac..6758bbf 100644 --- a/poverty-mapping/Dockerfile +++ b/poverty-mapping/Dockerfile @@ -15,4 +15,8 @@ RUN rm -f /var/www/html/uploads && mkdir -p /var/www/html/uploads # Set ownership and permissions for uploads directory RUN chown -R www-data:www-data /var/www/html && chmod -R 775 /var/www/html/uploads +# Increase PHP upload and post size limits +RUN echo "upload_max_filesize = 10M" > /usr/local/etc/php/conf.d/uploads.ini \ + && echo "post_max_size = 10M" >> /usr/local/etc/php/conf.d/uploads.ini + EXPOSE 80 diff --git a/poverty-mapping/index.html b/poverty-mapping/index.html index 3fe4514..c38c103 100644 --- a/poverty-mapping/index.html +++ b/poverty-mapping/index.html @@ -1883,6 +1883,7 @@ function openEdit(id){ payload.assistance_notes = null; } (async function(){ + let updateSuccess = false; try{ const respUpdate = await fetch('src/api/update_lokasi.php',{method:'POST',headers:buildHeaders(),body:JSON.stringify(payload),credentials:'same-origin'}); const jrUpdate = await respUpdate.json().catch(()=>null); @@ -1890,7 +1891,7 @@ function openEdit(id){ const reason = jrUpdate && jrUpdate.error ? jrUpdate.error : 'unknown'; showToast('Gagal menyimpan perubahan: ' + reason, 'error', 6000); } else { - try{ showToast('Perubahan tersimpan', 'success', 2600); }catch(e){} + updateSuccess = true; // optimistically update marker on the map so UI reflects change immediately try{ const idStr = String(id); @@ -1915,19 +1916,30 @@ function openEdit(id){ }catch(e){} } }catch(e){ console.error('update failed', e); showToast('Gagal menyimpan perubahan: ' + (e && e.message ? e.message : e), 'error', 6000); } - // use captured file from modal submit - if(file){ - try{ - const fdata = new FormData(); fdata.append('file', file); fdata.append('id', id); - const resp = await fetch('src/api/upload_photo.php',{method:'POST',headers:buildHeaders(null),body:fdata,credentials:'same-origin'}); - const jr = await resp.json().catch(()=>null); - if(!jr || !jr.success){ - const reason = jr && (jr.error || (jr.last_error && jr.last_error.message)) ? (jr.error || jr.last_error.message) : 'unknown'; - showToast('Gagal mengunggah foto: ' + reason, 'error', 7000); - } else { - showToast('Foto berhasil diunggah', 'success', 3000); + + if(updateSuccess){ + let uploadSuccess = true; + if(file){ + try{ + const fdata = new FormData(); fdata.append('file', file); fdata.append('id', id); + const resp = await fetch('src/api/upload_photo.php',{method:'POST',headers:buildHeaders(null),body:fdata,credentials:'same-origin'}); + const jr = await resp.json().catch(()=>null); + if(!jr || !jr.success){ + uploadSuccess = false; + const reason = jr && (jr.error || (jr.last_error && jr.last_error.message)) ? (jr.error || jr.last_error.message) : 'unknown'; + showToast('Gagal mengunggah foto: ' + reason, 'error', 7000); + } else { + showToast('Foto berhasil diunggah', 'success', 3000); + } + }catch(e){ + uploadSuccess = false; + console.error('upload failed',e); + showToast('Gagal mengunggah foto: ' + (e && e.message ? e.message : e), 'error', 7000); } - }catch(e){ console.error('upload failed',e); showToast('Gagal mengunggah foto: ' + (e && e.message ? e.message : e), 'error', 7000); } + } + if(uploadSuccess){ + showToast('Perubahan tersimpan', 'success', 2600); + } } loadData(); })(); diff --git a/tugas-spbu/Dockerfile b/tugas-spbu/Dockerfile index 93b506b..cfc290c 100644 --- a/tugas-spbu/Dockerfile +++ b/tugas-spbu/Dockerfile @@ -9,4 +9,8 @@ COPY . /var/www/html/ # Set ownership and permissions RUN chown -R www-data:www-data /var/www/html +# Increase PHP upload and post size limits +RUN echo "upload_max_filesize = 10M" > /usr/local/etc/php/conf.d/uploads.ini \ + && echo "post_max_size = 10M" >> /usr/local/etc/php/conf.d/uploads.ini + EXPOSE 80