0

In CakePHP view, When I try this code

    <?php echo $form->input('download_link', array('type'=>file)); ?>>

whose HTML output is

<input type="file" name="data[Publication][download_link]" value="" id="PublicationDownloadLink" />

is not working

but Plain HTML form in same view is working

<input type="file" name="download_link" class="engInput" />

Could somebody please explain why? Thanks in advance.

4
  • Thank you for your quick reply. But it's still not working. Please look at the question again, I've updated it. Commented Jan 5, 2012 at 6:56
  • 1
    what do you mean by 'not working'? It is outputting html, as it is suppose to. Commented Jan 5, 2012 at 7:13
  • In controller, if I put this code code $test=$_FILES["download_link"]["type"]; var_dump($test); code CakePHP code returns null but Plain HTML returns file type. Commented Jan 5, 2012 at 9:52
  • 2
    Cake stores the POST values of a form in a data array for you, which can be accessed as $this->data or $this->request->data. Mixing and matching reserved PHP variables and Cake is probably not wise at this particular point. Commented Jan 5, 2012 at 10:00

1 Answer 1

3

It should be:

input('download_link', array('type'=>'file'));

(Note the quotes around file)

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.