0

I have a small issue actually getting variable to show - let alone how to figure out why my images are not uploading. On my form I have the following textarea -

<input type="file" name="imageNew" />

in the page to which this form is posted I have -

$imagetoshow = $_REQUEST['imageNew']; echo "the image is " + $imagetoshow; exit();

I simply cant see why this is displaying a "0"? What I think I need is for someone to point out the obvious to me - obvious to you, not to me. Then I can get on with figuring out why the file isn't uploading.

Thanks in advance.

2 Answers 2

2

Files work a little differently... You need to access the $_FILES superglobal.

http://www.php.net/manual/en/features.file-upload.post-method.php

(From that page as well: Note: Be sure your file upload form has attribute enctype="multipart/form-data" otherwise the file upload will not work.)

Sign up to request clarification or add additional context in comments.

8 Comments

Yeah it does have the multipart/form-data. The link provided is actually where I started with my upload.php file, but the $_REQUEST is so that I can grab the posted values for later.
You mean that you want to do something different than obtaining the file? If so, what exactly are you trying to do and it's not working?
Sorry, I probably haven't explained myself too well... i need this value to construct an sql INSERT statement
@Andrew you can get the value, but its going to be part of $_FILES, understand?
At some stage it worked, but I'm trying to adapt the uploads.php file to accomodate a different upload to a different db table and inexplicably this no longer seems to get a value from the previous form.
|
2

To get files, you need to use $_FILES, not $_POST, and the form needs to have enctype="multipart/form-data". Check out the following link for more about file uploads in PHP: http://www.php.net/manual/en/features.file-upload.php

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.