Eduardo Fuerte
asked on
Could you point a way on how to obtain the a file's name to be presented on a Codeigniter view?
Hi Experts
Could you point a way on how to obtain the a file's name to be presented on a view?
The file name and complete path remain on a table column.
My tentative is:
The table's column that contains the file's name to be presented.
Could you check and possibly suggest something?
Thanks in advance
Could you point a way on how to obtain the a file's name to be presented on a view?
The file name and complete path remain on a table column.
My tentative is:
<script type="text/javascript">
$(function () {
var serv = $(this).parents('.modal').find('.id_reclamacao').val();
$.ajax({
// Codeigniter Controller
url: baseurl+'reclamacao/get/' + serv,
type: 'post',
cache: false,
contentType: false,
processData: false,
dataType: 'json',
data: serv,
success: function (data) {
var anexo = data['anexo'];
$('<p/>').text(anexo).appendTo(document.body);
},
error: function(jqXHR) {
bootbox.alert(jqXHR.responseText);
}
});
});
</script>
The table's column that contains the file's name to be presented.
Could you check and possibly suggest something?
Thanks in advance
ASKER
Hi
Please desconsider image img_EE_111016_005.png - I forgot to delete it. The relevant imageto this question is appearing.
Please desconsider image img_EE_111016_005.png - I forgot to delete it. The relevant imageto this question is appearing.
ASKER
Here is the code:
The relevant part I'm trying to implement starts at line 560
codigo_tela_131016.php
The relevant part I'm trying to implement starts at line 560
codigo_tela_131016.php
Could you point a way on how to obtain the a file's name to be presented on a view?Which filename are we looking for ?
ASKER
I understand - but I need to see where that column is in the HTML. The only reference I can find in your code to anexo is this
<!-- Anexo -->
<hr>
Where is the html that generates the image you posted?
<!-- Anexo -->
<hr>
<div class='row'>
<div class="col-xs-12 mb20">
<label for="anexo" class="field-label text-muted mb10">Anexo</label>
<input name="fileuser" id="fileuser" type="file" class="form-control gui-input br-light light" placeholder="">
</div>
</div>
Which is a file input and where the label Anexo is capitalised - where as in the image in your previous post it is a small letter.Where is the html that generates the image you posted?
ASKER
The jQuery above runs ok to download the file when the "Download file" button is clicked.
What I need is to present the filename to be downloaded previously - making it possible to disable the button if the column anexo has no content, and to present the content if the column has a content.
What I need is to present the filename to be downloaded previously - making it possible to disable the button if the column anexo has no content, and to present the content if the column has a content.
ASKER
Our messages crossed... just a moment.
ASKER
The html anexo that you saw refers to upload feature:
What I need is to present the "anexo" previously uploaded or disable the "Download" if no file was uploaded when editing...
<!-- Anexo -->
<hr>
<div class='row'>
<div class="col-xs-12 mb20">
<label for="anexo" class="field-label text-muted mb10">Anexo</label>
<input name="fileuser" id="fileuser" type="file" class="form-control gui-input br-light light" placeholder="">
</div>
</div>
<script type="text/javascript">
$(function () {
$('#fileupload').fileupload({
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
});
</script>
What I need is to present the "anexo" previously uploaded or disable the "Download" if no file was uploaded when editing...
Yes I understand but I don't know what the HTML for the anexo file is displayed.
ASKER
It's displayed just to point that a file exists to be downloaded and what is its name.
In the picture "name of the file to be downloaded" (previously uploaded)
In the picture "name of the file to be downloaded" (previously uploaded)
ASKER
And it just displays the db table's column content obtained in jQuery.
Ok, but as I understand it your question is how to get the filename out of that bit of HTML - and if we can't see the HTML that contains the filename I am not sure how to proceed.
ASKER
Isn't it possible to print directly in the document body ?
like:
like:
$('<p/>').text(anexo).appendTo(document.body);
Yes, but I thought you wanted this
Could you point a way on how to obtain the a file's name to be presented on a view?I interpret that to mean the filename is somewhere on the page (remain on a table column) and you want to retrieve it.
The file name and complete path remain on a table column.
ASKER
Oh... I understand now your doubt.
it's not a HTML table - it's a Database table that just has the value I need in the column called anexo.
This picture represents DB table column value:
And this code - not yet working, to retrieve column values:
Could you suggest what's needed?
it's not a HTML table - it's a Database table that just has the value I need in the column called anexo.
This picture represents DB table column value:
And this code - not yet working, to retrieve column values:
<script type="text/javascript">
$(function () {
var serv = $(this).parents('.modal').find('.id_reclamacao').val();
$.ajax({
// Codeigniter Controller
url: baseurl+'reclamacao/get/' + serv,
type: 'post',
cache: false,
contentType: false,
processData: false,
dataType: 'json',
data: serv,
success: function (data) {
var anexo = data['anexo'];
// Presents the column value
$('<p/>').text(anexo).appendTo(document.body);
},
error: function(jqXHR) {
bootbox.alert(jqXHR.responseText);
}
});
});
</script>
(this code is adapted from the download feature of the modal view)Could you suggest what's needed?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't know if I correctly coded and where is the correct place to post this jQuery:
The value must be presented just bellow "Reembolso" accordingly to:
So, in the middle of HTML:
But it is not functional.
The similar code called when the "Download do Arquivo" button is clicked - at the botton of HTML is functional:
The value must be presented just bellow "Reembolso" accordingly to:
So, in the middle of HTML:
....
<div class="col-xs-4 mb20 reembolso" style="display: none;">
<label for="reembolso" class="field-label text-muted mb10">Reembolso</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-money c-gray"></i>
</span>
<span class="validar">
<input type="text" name="reembolso" class="reembolso form-control gui-input br-light light" placeholder="">
</span>
</div>
</div>
</div>
.....
<script type="text/javascript"
var baseurl2 = "<?php print base_url(); ?>"
$(function () {
var serv = $(this).parents('.modal').find('.id_reclamacao').val();
$.ajax({
url: baseurl2+'reclamacao/get/' + serv,
type: 'post',
cache: false,
dataType: 'json',
data: serv,
success: function (data) {
var anexo = data['anexo'];
console.log(data); // WHAT DOES THIS OUTPUT
// Presents the column value
$('<p/>').text(anexo).appendTo(document.body);
},
error: function(jqXHR) {
bootbox.alert(jqXHR.responseText);
}
});
});
</script>
But it is not functional.
The similar code called when the "Download do Arquivo" button is clicked - at the botton of HTML is functional:
var baseurl = "<?php print base_url(); ?>";
$(".download").click(function(){
// Usa o id_reclamacao do 1.o modal- Edit que detém o valor
var serv = $(this).parents('.modal').find('.id_reclamacao').val();
$.ajax({
url: baseurl+'reclamacao/get/' + serv,
type: 'post',
cache: false,
contentType: false,
processData: false,
dataType: 'json',
data: serv,
success: function (data) {
var anexo = data['anexo'];
//alert(anexo);
// Faz o download
window.open(anexo);
},
error: function(jqXHR) {
bootbox.alert(jqXHR.responseText);
}
});
});
Remember this
$('<p/>').text(anexo).appendTo(document.body);
Will be added at the very end of the document - is that where you want it?
ASKER
Yes, it could be a solution.
But it's not presented anywhere, I don't know why.
But it's not presented anywhere, I don't know why.
Are you sure.
Try viewing the HTML in the console - look down where the closing </body> tag is - are you sure it is not there?
Try viewing the HTML in the console - look down where the closing </body> tag is - are you sure it is not there?
ASKER
Julian
I opened a paralell question in this subject since the needed value can be obtained in a textbox:
https://www.experts-exchange.com/questions/28976425/Could-you-point-how-to-manipulate-a-textbox-value-before-it's-presented.html
Could you give a look?
I opened a paralell question in this subject since the needed value can be obtained in a textbox:
https://www.experts-exchange.com/questions/28976425/Could-you-point-how-to-manipulate-a-textbox-value-before-it's-presented.html
Could you give a look?
ASKER
Thanks for help!
You are welcome.
Can you show us the HTML for the table.