Jump to content

$_FILES error on tmp_name


jkkenzie

Recommended Posts

Hello!

When i

print_r($_FILES['attachment']);

I get:

Array ( [name] => FormC1.pdf [type] => application/pdf [tmp_name] => /tmp/phpa4lt0I [error] => 0 => 23051 )

 

there is an error on temp_name,

I want to get the FILE PATH as string so as i can supply it to a variable, which i use on email function.

 

thanks in advance.

Link to comment
Share on other sites

HTML browsers like to strip the whitespace from the source, and show it as a single space. So the proper output of the print_r () statement is:

Array (
    [name] => FormC1.pdf
    [type] => application/pdf
    [tmp_name] => /tmp/phpa4lt0I
    [error] => 0
    [size] => 23051
)

 

As you can see, there are no errors here. With the value for the error index being 0.

However, you are incorrect in your assumption on how to get the file path. I recommend that you read through the PHP manual for file uploads, as it will teach you how to do this.

 

PS: Remember to validate input and escape output, otherwise you'll be open for attackers to overwrite any file on your server.

 

Link to comment
Share on other sites

Here's a couple of articles that helps explain the two terms, and how to accomplish them:

http://msmvps.com/blogs/alunj/archive/2010/05/31/1771098.aspx

http://en.wikipedia.org/wiki/Secure_input_and_output_handling

 

A very detailed guide:

https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.