0

I have a lot of forms contained within a CMS I created. They have all been working fine up until today. The issue I am having is related to files being uploaded and the $_FILES array containing odd characters.

Contained within a form I have:

<tr>
    <td>Related PDF File:</td>
    <td><input type="file" name="pdfFile" size=50" value="<? pv($frm["pdfFile"]) ?>"></td>
</tr>

On submit it returns back to my script and I validate if the field has a file submitted:

if($_FILES['pdfFile']['name'] != '' && $_FILES['pdfFile']['error'] == 0) {
    $up_file->save($CFG->dirroot . "/docs/services/", "pdfFile", 1);
    $frm['pdfFile'] = $up_file->getFilename('pdfFile');
}

The issue is if I display my $_FILES array when the field has nothing submitted I get the following:

Array
(
    [pdfFile] => Array
        (
            [name] => ò…
            [type] => 
            [tmp_name] => 
            [error] => 4
            [size] => 0
        )
)

The [name] has some funky special characters within. Has anyone ever seen this? It is only happening on one of my servers. And if the input field actually has a submitted file, there is no issue.

Thanks in advance for any comments.

5
  • What's in $frm["pdfFile"]? By the way you can't set it like that. Otherwise you could upload files from a user's computer without the user knowing it. Commented Nov 17, 2011 at 18:34
  • Why are you trying to set the value of the input to whatever that is? Browsers usually ignore this since it would be a security hazard to allow pages to specify which file is to be uploaded. Commented Nov 17, 2011 at 18:38
  • I've seen that funky special character ò (as you name it), it's just a character. What's your problem with it? Commented Nov 17, 2011 at 18:40
  • $frm is array of values used throughout the form loaded from a database. This form is contained within a CMS with account privileges. You require access just to view this form. Commented Nov 17, 2011 at 18:41
  • I have seen this character many times, used in various languages. My question is why is it in my $_FILES array. I have removed the setting of the input as it is not required. Commented Nov 17, 2011 at 18:43

2 Answers 2

2

Figured out what the issue was. PHP was recently updated by our hosting provider to 5.3.8. There is a bug in this release which removes the first character in an uploaded file. You can see the bug here: $_FILES 'name' missing first character after upload.

For some reason magic_quotes_gpc was set to on after the update. Turned it off, and all is good now.

Thanks for your comments.

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

Comments

0
[error] => 4

Using documentation:

UPLOAD_ERR_NO_FILE

    Value: 4; No file was uploaded.

Make sure u have enctype="multipart/form-data" attribute in your <form> tag.

1 Comment

Yes I have the correct enctype, and there was no file uploaded as the field was left blank. If I submit a file to be uploaded I have no issues.

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.