I am new to Symfony framework. I am developing a small application in which one of the tasks is to provide a file upload feature. I am unable to accomplish this task even after several attempts. Also, I do not get any error messages. I understand that all uploaded files have to be stored in the path web/uploads. Though the file link is stored in the database, the file is not saved in the web/uploads. The code works properly in regular PHP/MySQL set up.Here is the code:
<input type='button' value='Add New Drive Cycle' onClick='newCycle()' />
If the user clicks on the "Add New Drive Cycle" button the form will generate via javascript function a "newCycle"
javascript function code :
- Code: Select all
function newCycle(){
document.getElementById('msg').style.display='none';
var str = "<form method='post' enctype='multipart/form-data' action='' name='formCycle'>"+
"<input type='hidden' value='TRUE' name='msg' />"+
"<table>" +
"<tr> <td colspan=2 align='center' style='background-color: #c4e0f0; font-size: 18; font-weight: bold'> New Cell</td> </tr> " +
'<?php echo str_replace("\n", "", $form_cycle->__toString()) ?>' +
"<tr><td><b>NeWare cycle profile (.job) file:</b></td><td> <input type='file' name='jobfile' id='jobfile' onchange='checkExt(this,\"fname\",\"submit\")' /> " +
"<tr> <td colspan=2 align='center'> <input type='button' value='Add' onClick='return funCycle();' id='submit' name='submit' /> " +
"<input type='button' value='Cancel' onClick='cancel()' /> </td> </tr> " +
"<tr> <td align='center' colspan=2> <div id='errstr' style='color: #FF0000' > </div> </td> </tr> " +
"</table>"
"</form>";
document.getElementById('addnew').innerHTML = str;
}
code for the '<?php echo str_replace("\n", "", $form_cycle->__toString()) ?>'
the above tag inside in the javascript:
- Code: Select all
$this->form_cycle = new sfForm();
$this->form_cycle->setWidgets(array(
'name' => new sfWidgetFormInputText(),
'celltype' => new sfWidgetFormChoice(array('choices' => array('7' => 'Sanyo E', '19' => 'Lishen 6.5 AJ'))),
'notes' => new sfWidgetFormInputText(),
'fname' => new sfWidgetFormInputHidden(),
'file' => new sfWidgetFormInputFile(),
));
I am able to save the file path in the DB, but cannot move the file to a specific folder.
Can anyone help me out?
Regards
Karthick
