Forums

name of fileUpload

paolodefalco 13 Nov, 2011
Hi,
i can't store the name of a fileupload (and its path) in a field of the table where i can store the other data send by the form i use. The file is well uploaded in the default path....

What can i do?

Regards, Paolo
GreyHead 14 Nov, 2011
Hi Paolo,

Provided that the File Upload action is before the DB Save action you should be able to save the file name. Yuu may find it helps to get my Upload Files [GH] action from here which makes the data more available.

The file data will be made available in a series of form data values: the file name in {input_name}; the file size in {input_name_size}; the file size in {input_name_url}; and the file url in {input_name_url}. In each case replace input_name with the name of the input in your form e.g. {input_file_0_path}


Bob
paolodefalco 14 Nov, 2011
Hi Bob,
first of all, thanks for your answer...unfortunately the problem remain unsolved.
Now i'm be able to store the file extension only (pdf or docx ....)
I attach some images of the setting ansd the code..
Once again...thanks a lot



<?php
$user =& JFactory::getUser();
$nomeutente = $user->username;

$db =& JFactory::getDBO();
$MyQry = 'SELECT idinsegnante from dbo_coordinatori where Userid = "' .$nomeutente. '"';
$db->setQuery( $MyQry );
$_SESSION[idInsegnante] = $db->loadResult();
//echo $_SESSION[idInsegnante]
?>
<br/>
<br/>
<div class="ccms_form_element cfdiv_header" id="_p_style_text_align_center_strong_invio_programmazioni_didattiche_strong_p___container_div"><p style="text-align: center;"><strong>Invio programmazioni didattiche</strong></p>
<br/>
<div class="clear"></div></div><div class="ccms_form_element cfdiv_select" id="classe_container_div"><label for="CodClasse">Classe</label><select size="1" label_over="0" hide_label="0" style="width:250px;" id="CodClasse" class=" validate['required']" title="" type="select" name="CodClasse"><option value="">- Seleziona la classe -</option>
<?php
$db =& JFactory::getDBO();
$query = 'SELECT idclasse, descrclasse from scrutini_classi, dbo_coordinatori, scrutini_crossinsmatclassi where dbo_coordinatori.userid = "' .$nomeutente. '" and dbo_coordinatori.idinsegnante = scrutini_crossinsmatclassi.codinsegnante and idclasse = codclasse group by descrclasse';
$db->setQuery( $query );
$righe = $db->loadObjectList();
foreach ( $righe AS $riga) {
$option = $riga->idclasse;
if ($riga->descrclasse) $option .= ', '. $riga->descrclasse;
echo "<option value='" .$riga->idclasse. "'>" .$riga->descrclasse. "</option>";
} ?>
</select>


<div class="clear"></div><div id="error-message-CodClasse"></div></div><div class="ccms_form_element cfdiv_select" id="materia_container_div"><label for="CodMateria">Materia</label><select size="1" label_over="0" hide_label="0" style="width:250px;" id="CodMateria" class=" validate['required']" title="" type="select" name="CodMateria">
<option value="">- Seleziona la materia -</option>
<?php
$db =& JFactory::getDBO();
$query = 'SELECT idmateria, descrizione from scrutini_materie, dbo_coordinatori, scrutini_crossinsmatclassi where dbo_coordinatori.userid = "' .$nomeutente. '"  and dbo_coordinatori.idinsegnante = scrutini_crossinsmatclassi.codinsegnante and idmateria = codmateria group by codmateria';
$db->setQuery( $query );
$righe = $db->loadObjectList();
foreach ( $righe AS $riga) {
$option = $riga->idmateria;
if ($riga->descrizione) $option .= ', '. $riga->descrizione;
echo "<option value='" .$riga->idmateria. "'>" . $riga->descrizione. "</option>";
} ?>
</select>


<div class="clear"></div><div id="error-message-CodMateria"></div></div><div class="ccms_form_element cfdiv_select" id="anno_container_div"><label for="A_S">Anno</label><select size="1" label_over="0" hide_label="0" style="width:250px;" id="A_S" class=" validate['required']" title="" type="select" name="A_S">
<option value="0" selected>- Seleziona a.s -</option>
<option value="13">2011-2012</option>
<option value="14">2012-2013</option>
<option value="15">2013-2014</option>
<option value="16">2014-2015</option>
<option value="17">2015-2016</option>
</select>
<div class="clear"></div><div id="error-message-A_S"></div></div>
<div class="ccms_form_element cfdiv_file" id="selezionare_il_file_container_div" >
<label for="FileProgrDid">Selezionare il file</label>

<input type="hidden" name="FileProgrDid" value="" alt="ghost" />
<input id="FileProgrDid" class=" validate['required']" title="" label_over="0" hide_label="0" type="file" name="FileProgrDid" style="height:28px; width:250px;" />
<div class="clear"></div><div id="error-message-FileProgrDid"></div></div>


<input id="CodDocente" type="hidden" value="<?php echo $_SESSION[idInsegnante];?>" name="CodDocente" />

<div class="ccms_form_element cfdiv_submit" id="input_submit_5_container_div">
<input name="input_submit_5" class="" style="height:28px;" value="Invia programmazione" type="submit" />
<div class="clear"></div><div id="error-message-input_submit_5"></div></div>
GreyHead 14 Nov, 2011
Hi Paolo,

Looks OK to me. Please add a Debugger action to the On Submi event and post the results here.

Bob
paolodefalco 15 Nov, 2011
Hi Bob,
if i don't put {FileProgrDid} in the Field Name parameter, it seems ok...i'm just a little bit perplexed.
What do you think about it?

Thanks...again
Paolo
GreyHead 16 Nov, 2011
Hi Paolo,

I took a quick look at the code and don't immediately see where the problem is. Please try putting {file_name} in the Field Name parameter instead of {FileProgrDid} and see if that works instead.

I'll try to take a better look later, I suspect it may be because {FileProgrDid} included the file suffix and not just the base name.

Bob
This topic is locked and no more replies can be posted.