Move uploaded file function is not working

0 votes

I have been working on a website and I want the user to be able to upload files which is why I'm trying to learn how to do that. I have researched it and it said that I had to use the function move_uploaded_file(). I wrote the code just like it was on the example, but it wouldn't work. Please help me, I'm new at these. Here's what I've done so far:

<!DOCTYPE html> 
<html> 
          <head> 
          </head> 
<body> 
        <form action="upload_file.php" method="POST" enctype="multipart/form-data"> 
            <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> 
            <input type="file"name="file"> 
            <input type="submit"> 
      </form> 
</body> 
<html>


This is the upload_file.php:

<!DOCTYPE html> 
<html> 
    <head> 
      <head> 
          <body> 
            <?php 
              $move = "/Users/George/Desktop/uploads/"; 
                echo $_FILES["file"]['name']."<br>"; 
                echo $_FILES["file"]['tmp_name']."<br>"; 
                echo $_FILES["file"]['size']."<br>"; 
                echo $_FILES['file']['error']."<br>"; move_uploaded_file($_FILES['file']['name'], $move);      ?> 
<body> 
<html>
Feb 22 in Others by Rahul
• 8,980 points
23 views

1 answer to this question.

0 votes

The file will be stored in a temporary location, so use tmp_name instead of name:

if (move_uploaded_file($_FILES['image']['tmp_name'], __DIR__.'/../../uploads/'. $_FILES["image"]['name'])) { 
      echo "Uploaded"; } 
else { 
    echo "File not uploaded"; 
}

answered Feb 22 by Aditya
• 7,280 points

Related Questions In Others

+1 vote
0 answers
0 votes
1 answer

why aws s3 transfer acceleration is not working?

Essentially, rather than travelling the Internet to ...READ MORE

answered Mar 24 in Others by Edureka
• 8,820 points
47 views
0 votes
1 answer

why aws s3 transfer acceleration is not working?

Amazon S3 Transfer Acceleration is a bucket-level ...READ MORE

answered Mar 24 in Others by Edureka
• 8,820 points
40 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
508 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
8,995 views
0 votes
1 answer

Failure uploading Image on AmazonS3 with PHP SDK

Try this, I took it out from ...READ MORE

answered May 4, 2018 in AWS by Cloud gunner
• 4,650 points
2,024 views
0 votes
1 answer

Trying to call AWS API via PHP

Try using AWS SDK for PHP, Link ...READ MORE

answered Jun 6, 2018 in AWS by Cloud gunner
• 4,650 points
961 views
0 votes
1 answer

TypeError: $.ajax(...) is not a function?

Please double-check if you're using the full-version ...READ MORE

answered Feb 22 in Others by Aditya
• 7,280 points
25 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP