-3

I'm uploading image in php using (move_uploaded_file()) function, but image is not uploading in the folder where i want to upload it even after mentioning the folder path in macbook m1 chip

this is the code, that i am trying

6
  • 6
    Please don't post images of code or errors! Commented Jun 18, 2024 at 7:09
  • Your upload code gives you feedback. What is it? Remember, we cannot run the code on your Mac, only you can. Commented Jun 18, 2024 at 7:29
  • You have a hidden input named "MAX_FILE_SIZE". It is not used. Why is it there? Commented Jun 18, 2024 at 7:31
  • @KIKOSoftware See this. Commented Jun 18, 2024 at 7:49
  • 1
    @KIKOSoftware The real problem here is that MAX_FILE_SIZE equals 30000 (just like in the PHP documentation), which means that images above 30KB will be refused. That's what happens when you copy code without understanding it... Commented Jun 18, 2024 at 8:23

1 Answer 1

0

I see there are two mistakes within your code.

First with the $uploaddir. Is it a relative path? If yes then why it contains htdocs? it should not. Path should look like /directory

Secondly, you forget to add a slash between the dir and basename. So your script is considering it as a whole name of the directory.

$uploadfile = $uploaddir.'/'.basename($_FILES['userfile']['name']);

Check the doc here

move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.