samedi 9 janvier 2016

Can't upload image to website with PHP

Vote count: 0

I asked a similar question about a week ago, but since I got no answer and the status of the code has changed quite a lot, I've decided to open a new thread. Hope there is no problem ;)

I'm creating a website where people can write comments. When doing so, a name and an image are asked for, and then displayed on the site. However, I can't get the images properly uploaded to my folder. Here's the form in HTML (which is displayed using AJAX):

<input name='image' id ='image' type='file' accept='image/jpg' />

Here the PHP that I use to upload the image (with no success...):

if($_FILES['image']['name']) {
        echo 'File has been uploaded by user';
            echo 'No errors';
            $target = 'images/profile/users/'.$username.'.jpg';
            move_uploaded_file($_FILES['image']['tmp_name'], $target);
            echo 'Should be uploaded';
            echo 'Error:  '.$_FILES['image']['error'];

Whenever I try to upload a file, the first echo is not displayed (no 'File has been uploaded by user' is written on the screen). No other messages displayed, either... Any ideas?

Thanks a lot


asked 55 secs ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at

Can't upload image to website with PHP

Aucun commentaire:

Enregistrer un commentaire