javascript - Error 503 (Backend fetch failed) while uploading image -
i want users able upload image files, of them receive error message
failed load resource: server responded status of 503 (backend fetch failed)
here codes
in javascript
function uploadimage() { if ($("#file").val() != "") $("#form-upload").submit(); }
in php
if ($_files["file"]["size"] > 0) { if ($_files["file"]["size"] <= 1024 * 1024 * 5) { $name = strtotime("now") . "-" . generaterandomstring(); if (move_uploaded_file($_files["file"]["tmp_name"], "../img/backgrounds/" . $name . ".png")) { ?> <script>window.parent.receiveanswer("success", "./img/backgrounds/<?= $name ?>.png", "<?= $name ?>");</script> <?php } else { // upload failed ?> <script>window.parent.receiveanswer("error", "upload failed!");</script><?php } } else { // file big ?> <script>window.parent.receiveanswer("error", "image big!");</script><?php } } else { // file empty ?> <script>window.parent.receiveanswer("success", "empty file submitted -> no image");</script><?php } function generaterandomstring($length = 100) { $characters = "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; $characterslength = strlen($characters); $randomstring = ""; ($i = 0; $i < $length; $i++) $randomstring .= $characters[rand(0, $characterslength - 1)]; return $randomstring; } function isallowedexstension() { // @todo }
my server running php version 7.0
Comments
Post a Comment