Getting 500 error when sending a file via axios





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















First I want to download image from external server, then I want to send post request with that image to my laravel REST api via axios, but when I try to do it I get that error. When I send request via postman everything works.



Here you are blob response:



Blob(3382513) {size: 3382513, type: "image/jpeg"}
size: 3382513
type: "image/jpeg"
__proto__: Blob
size: (...)
slice: ƒ slice()
type: (...)
constructor: ƒ Blob()
Symbol(Symbol.toStringTag): "Blob"
get size: ƒ size()
get type: ƒ type()
__proto__: Object


My controller



public function store(Request $request)
{
return Image::make($request->file)->response();
}


JavaScript



async confirmWallpaper(wallpaper) {
let image;
await fetch(wallpaper.image_url)
.then(res => res.blob())
.then(blob => {
image = blob;
});

let data = new FormData();
data.append('file', image);

axios.post('/api/wallpaper', data,
{
header : {
'Content-Type' : 'multipart/form-data'
}
},
)
.then(res => res)
.then(res => {
if("error" in res) {
this.message = res.error.message;
}
if("data" in res) {
console.log(JSON.stringify(res.data));
}
})
.catch(error => {
console.log(JSON.stringify(error.response));
});


Thank you and have happy new year :)










share|improve this question




















  • 1





    Have you checked the error logs that laravel produces? Or enabled Laravel's APP_DEBUG to see the exact error message?

    – John Ellmore
    Jan 3 at 22:10











  • There's nothing about it in logs :(. APP_DEBUG is turned on

    – Arturek
    Jan 3 at 22:13








  • 1





    "then I changed in php.ini memory limit" 👈 did you restart Apache after making that change?

    – Phil
    Jan 3 at 23:11











  • Yes, I did. I will check this out again tomorrow, because now i'm in bed. Good night :)

    – Arturek
    Jan 3 at 23:37











  • Btw. thank you guys for dedicating your time to solve somebody's problem just for free. I really appreciate it ❤ and I want to tell that you are really awesome people 😁

    – Arturek
    Jan 3 at 23:57


















0















First I want to download image from external server, then I want to send post request with that image to my laravel REST api via axios, but when I try to do it I get that error. When I send request via postman everything works.



Here you are blob response:



Blob(3382513) {size: 3382513, type: "image/jpeg"}
size: 3382513
type: "image/jpeg"
__proto__: Blob
size: (...)
slice: ƒ slice()
type: (...)
constructor: ƒ Blob()
Symbol(Symbol.toStringTag): "Blob"
get size: ƒ size()
get type: ƒ type()
__proto__: Object


My controller



public function store(Request $request)
{
return Image::make($request->file)->response();
}


JavaScript



async confirmWallpaper(wallpaper) {
let image;
await fetch(wallpaper.image_url)
.then(res => res.blob())
.then(blob => {
image = blob;
});

let data = new FormData();
data.append('file', image);

axios.post('/api/wallpaper', data,
{
header : {
'Content-Type' : 'multipart/form-data'
}
},
)
.then(res => res)
.then(res => {
if("error" in res) {
this.message = res.error.message;
}
if("data" in res) {
console.log(JSON.stringify(res.data));
}
})
.catch(error => {
console.log(JSON.stringify(error.response));
});


Thank you and have happy new year :)










share|improve this question




















  • 1





    Have you checked the error logs that laravel produces? Or enabled Laravel's APP_DEBUG to see the exact error message?

    – John Ellmore
    Jan 3 at 22:10











  • There's nothing about it in logs :(. APP_DEBUG is turned on

    – Arturek
    Jan 3 at 22:13








  • 1





    "then I changed in php.ini memory limit" 👈 did you restart Apache after making that change?

    – Phil
    Jan 3 at 23:11











  • Yes, I did. I will check this out again tomorrow, because now i'm in bed. Good night :)

    – Arturek
    Jan 3 at 23:37











  • Btw. thank you guys for dedicating your time to solve somebody's problem just for free. I really appreciate it ❤ and I want to tell that you are really awesome people 😁

    – Arturek
    Jan 3 at 23:57














0












0








0








First I want to download image from external server, then I want to send post request with that image to my laravel REST api via axios, but when I try to do it I get that error. When I send request via postman everything works.



Here you are blob response:



Blob(3382513) {size: 3382513, type: "image/jpeg"}
size: 3382513
type: "image/jpeg"
__proto__: Blob
size: (...)
slice: ƒ slice()
type: (...)
constructor: ƒ Blob()
Symbol(Symbol.toStringTag): "Blob"
get size: ƒ size()
get type: ƒ type()
__proto__: Object


My controller



public function store(Request $request)
{
return Image::make($request->file)->response();
}


JavaScript



async confirmWallpaper(wallpaper) {
let image;
await fetch(wallpaper.image_url)
.then(res => res.blob())
.then(blob => {
image = blob;
});

let data = new FormData();
data.append('file', image);

axios.post('/api/wallpaper', data,
{
header : {
'Content-Type' : 'multipart/form-data'
}
},
)
.then(res => res)
.then(res => {
if("error" in res) {
this.message = res.error.message;
}
if("data" in res) {
console.log(JSON.stringify(res.data));
}
})
.catch(error => {
console.log(JSON.stringify(error.response));
});


Thank you and have happy new year :)










share|improve this question
















First I want to download image from external server, then I want to send post request with that image to my laravel REST api via axios, but when I try to do it I get that error. When I send request via postman everything works.



Here you are blob response:



Blob(3382513) {size: 3382513, type: "image/jpeg"}
size: 3382513
type: "image/jpeg"
__proto__: Blob
size: (...)
slice: ƒ slice()
type: (...)
constructor: ƒ Blob()
Symbol(Symbol.toStringTag): "Blob"
get size: ƒ size()
get type: ƒ type()
__proto__: Object


My controller



public function store(Request $request)
{
return Image::make($request->file)->response();
}


JavaScript



async confirmWallpaper(wallpaper) {
let image;
await fetch(wallpaper.image_url)
.then(res => res.blob())
.then(blob => {
image = blob;
});

let data = new FormData();
data.append('file', image);

axios.post('/api/wallpaper', data,
{
header : {
'Content-Type' : 'multipart/form-data'
}
},
)
.then(res => res)
.then(res => {
if("error" in res) {
this.message = res.error.message;
}
if("data" in res) {
console.log(JSON.stringify(res.data));
}
})
.catch(error => {
console.log(JSON.stringify(error.response));
});


Thank you and have happy new year :)







php laravel apache file-upload axios






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 23:01







Arturek

















asked Jan 3 at 22:07









ArturekArturek

85110




85110








  • 1





    Have you checked the error logs that laravel produces? Or enabled Laravel's APP_DEBUG to see the exact error message?

    – John Ellmore
    Jan 3 at 22:10











  • There's nothing about it in logs :(. APP_DEBUG is turned on

    – Arturek
    Jan 3 at 22:13








  • 1





    "then I changed in php.ini memory limit" 👈 did you restart Apache after making that change?

    – Phil
    Jan 3 at 23:11











  • Yes, I did. I will check this out again tomorrow, because now i'm in bed. Good night :)

    – Arturek
    Jan 3 at 23:37











  • Btw. thank you guys for dedicating your time to solve somebody's problem just for free. I really appreciate it ❤ and I want to tell that you are really awesome people 😁

    – Arturek
    Jan 3 at 23:57














  • 1





    Have you checked the error logs that laravel produces? Or enabled Laravel's APP_DEBUG to see the exact error message?

    – John Ellmore
    Jan 3 at 22:10











  • There's nothing about it in logs :(. APP_DEBUG is turned on

    – Arturek
    Jan 3 at 22:13








  • 1





    "then I changed in php.ini memory limit" 👈 did you restart Apache after making that change?

    – Phil
    Jan 3 at 23:11











  • Yes, I did. I will check this out again tomorrow, because now i'm in bed. Good night :)

    – Arturek
    Jan 3 at 23:37











  • Btw. thank you guys for dedicating your time to solve somebody's problem just for free. I really appreciate it ❤ and I want to tell that you are really awesome people 😁

    – Arturek
    Jan 3 at 23:57








1




1





Have you checked the error logs that laravel produces? Or enabled Laravel's APP_DEBUG to see the exact error message?

– John Ellmore
Jan 3 at 22:10





Have you checked the error logs that laravel produces? Or enabled Laravel's APP_DEBUG to see the exact error message?

– John Ellmore
Jan 3 at 22:10













There's nothing about it in logs :(. APP_DEBUG is turned on

– Arturek
Jan 3 at 22:13







There's nothing about it in logs :(. APP_DEBUG is turned on

– Arturek
Jan 3 at 22:13






1




1





"then I changed in php.ini memory limit" 👈 did you restart Apache after making that change?

– Phil
Jan 3 at 23:11





"then I changed in php.ini memory limit" 👈 did you restart Apache after making that change?

– Phil
Jan 3 at 23:11













Yes, I did. I will check this out again tomorrow, because now i'm in bed. Good night :)

– Arturek
Jan 3 at 23:37





Yes, I did. I will check this out again tomorrow, because now i'm in bed. Good night :)

– Arturek
Jan 3 at 23:37













Btw. thank you guys for dedicating your time to solve somebody's problem just for free. I really appreciate it ❤ and I want to tell that you are really awesome people 😁

– Arturek
Jan 3 at 23:57





Btw. thank you guys for dedicating your time to solve somebody's problem just for free. I really appreciate it ❤ and I want to tell that you are really awesome people 😁

– Arturek
Jan 3 at 23:57












1 Answer
1






active

oldest

votes


















0














I found in my apache error.log this:



[Thu Jan 03 17:56:16.405178 2019] [php7:error] [pid 2548:tid 1716] [client 
127.0.0.1:57143] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in C:\xampp\htdocs\wallpapers\vendor\symfony\debug\Exception\FatalErrorException.php on line 1, referer: http://laravel.local/panel/


then I changed in php.ini memory limit and it works



memory_limit=600M


Don't forget to restart your apache server :)






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030460%2fgetting-500-error-when-sending-a-file-via-axios%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I found in my apache error.log this:



    [Thu Jan 03 17:56:16.405178 2019] [php7:error] [pid 2548:tid 1716] [client 
    127.0.0.1:57143] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in C:\xampp\htdocs\wallpapers\vendor\symfony\debug\Exception\FatalErrorException.php on line 1, referer: http://laravel.local/panel/


    then I changed in php.ini memory limit and it works



    memory_limit=600M


    Don't forget to restart your apache server :)






    share|improve this answer




























      0














      I found in my apache error.log this:



      [Thu Jan 03 17:56:16.405178 2019] [php7:error] [pid 2548:tid 1716] [client 
      127.0.0.1:57143] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in C:\xampp\htdocs\wallpapers\vendor\symfony\debug\Exception\FatalErrorException.php on line 1, referer: http://laravel.local/panel/


      then I changed in php.ini memory limit and it works



      memory_limit=600M


      Don't forget to restart your apache server :)






      share|improve this answer


























        0












        0








        0







        I found in my apache error.log this:



        [Thu Jan 03 17:56:16.405178 2019] [php7:error] [pid 2548:tid 1716] [client 
        127.0.0.1:57143] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in C:\xampp\htdocs\wallpapers\vendor\symfony\debug\Exception\FatalErrorException.php on line 1, referer: http://laravel.local/panel/


        then I changed in php.ini memory limit and it works



        memory_limit=600M


        Don't forget to restart your apache server :)






        share|improve this answer













        I found in my apache error.log this:



        [Thu Jan 03 17:56:16.405178 2019] [php7:error] [pid 2548:tid 1716] [client 
        127.0.0.1:57143] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in C:\xampp\htdocs\wallpapers\vendor\symfony\debug\Exception\FatalErrorException.php on line 1, referer: http://laravel.local/panel/


        then I changed in php.ini memory limit and it works



        memory_limit=600M


        Don't forget to restart your apache server :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 4 at 12:33









        ArturekArturek

        85110




        85110
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54030460%2fgetting-500-error-when-sending-a-file-via-axios%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Angular Downloading a file using contenturl with Basic Authentication

            Monofisismo

            Olmecas