Email a file attachment from <input type=file> problem...

When submitting a form that contains <input type="file" name="test"> to a php script, I get an undefined index trying to retrieve the value of "test".

I don't need to upload the file to the server, I just need the path on the users computer, because when they submit the form, I'll email the file in an attachment.

How do I access the "test" value in the script?  All the other submitted values work fine.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

$test = $_POST['test'];

should work fine presuming that the forms method is POST
kbachAuthor Commented:

Not for <input type=file>

I've discovered that you have to use $_FILES['test']['name'] to retrieve the name of the input file.  Which is now working.  Unfortunately, I have another problem.  All of the variables now post fine on my local machine, but when I upload them to the server (which is using PHP 4.0.6) none of the variables POST through.  They are all zero-length strings.

Has anyone encountered this problem?

>> Not for <input type=file>

I tried this on my server and it works fine, it prints the file name

if (isset($_POST['submit'])) {
echo $_POST['file'];

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
<input type="file" name="file">
<input type="submit" name="submit">

anyway, for what you want to do i think youd benefit looking here:
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

if you're using PHP 4.0.6 you need to use $HTTP_POST_VARS and $HTTP_POST_FILES instead of $_POST and $_FILES respectively


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kbachAuthor Commented:
Thanks loz, you're right.  However, I also found HeadAcheMike's article helpful with a related problem that 4.0.6 was causing.  Would you guys object to 150 for loz and 50 for HeadAcheMike?

Thanks again to both of you.

go for it, it's your choice

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.