Home Ask Login Register

Developers Planet

Your answer is one click away!

ajt February 2016

change the default message on upload file cakephp

In cakephp I want to upload a file on a form entry, e.g. a resume to upload and also form entry of people's names, addresses etc. The problem is when I upload a file I get the message after the file is uploaded 'no file selected'. The function works but this message is confusing for the user as I want the name of the file displayed instead of 'no file selected'.

EDIT Next to the button Browse, the label appears 'No file Selected'. How do I suppress/alter this message?

UPDATE: Found a workaround answer which might not be the best solution.


echo $this->Form->input('reason', array('label' => 'Reason for Cancellation', 'style'=> "width:30%",'value'=>$reason));
echo __('Upload Attachment');
echo $this->Form->input('resume_file', array('type' => 'file'));
echo $this->Form->submit('Upload', array('name'=>'upload'));
echo $this->Form->end();


public function uploadfile() {

    if ($this->request->is('post')) {
        if (isset($this->request->data['upload'])) {
                if ($this->attachmentupload() && $this->Resume->save($this->request->data)) {
                    $this->Session->setFlash(__('The attachment has been saved'), 'flash_success');
                } else {
                    $this->Session->setFlash(__('The attachment could not be saved. Please, try again.'),'flash_alert');

public function attachmentupload() {

    $file = $this->request->data['Resume']['resume_file'];
    $resume_org_filename = $file['name'];
    $resume_filename = $file['name'];

    if ($file['error'] === UPLOAD_ERR_OK) {

        // Code to check if file with the same name exists. If it exists - add n towards the end
        $t = 0;
        $url = APP.'Resumes'.DS.$resume_f        


ajt March 2016

The answer is to suppress the label and add the element in a table/div with a label

Post Status

Asked in February 2016
Viewed 2,274 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life