Show the path of a file, before uploading it to a server

0

I have this code which assigns my file name to upload to my server, this is to register it.

string rutaPDF = Request.MapPath("PDFs_Landing/");
 Random ra = new Random();
 int numeroP = r.Next(5, 10000000);
 tituloLanzamiento = tituloLanzamiento.Replace(" ", "_");
 if (Directory.Exists(rutaPDF) == false)
     Directory.CreateDirectory(rutaPDF);
 string documento = Path.GetFileName(urlPdf.FileName);
 string extensionP = Path.GetExtension(documento);
 documento = documento.Substring(documento.LastIndexOf(".") + 1).ToLower();
 documento = "Documento_" + numeroP + '_' + Pais + extensionP;
 urlPdf.SaveAs(rutaPDF + documento);
 string urlPDF = "/Landing_Page/PDFs_Landing/" + archivo;
 nombreBanner = nombreBanner.Replace("_", " ");

What I want is that before registering, show me the destination route to be able to copy it. I saw an example which implements it like this:

<div class="col-md-6 col-md-offset-5">
    <div class="row">
    <div class="col-md-4">
    <div class="custom-input-file required">
    <input type="file" name="urlPdf" id="urlPdf" class="input-file" onchange="ValidarDocumento(this);" required />
    <label id="errorDoc"></label>
    PDF&nbsp;&nbsp;&nbsp;<i class="fa fa-file text-info"></i>
    <div class="archivo">Click para elegir...</div>
    </div>
    </div>
    </div>
    <a data-toggle="modal" data-target="#myModal">Mostrar Url de Destino</a>
</div>

And this

<div class="modal fade" id="myModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <p>
                    Ruta de la imagen del párrafo desde el que se ha hecho click en el modal:
                </p>
            </div>
        </div>
    </div>
</div>


<script>
  $('a[data-toggle=modal]').click(function(){
    var urlPdf = $(this).prev('input').attr('file');

    $($(this).data('target')+' .modal-header p').html(urlPdf);
  });
</script>

But it does not work for me

    
asked by JuankGlezz 29.05.2017 в 17:11
source

1 answer

0

Check your variables very well, since some are not defined. To be exact the variable of string urlPDF = "/Landing_Page/PDFs_Landing/" + **archivo**;

Now your real problem is how to figure out how to take your url and show it in the modal and after that send the url to save the generated file.

    
answered by 29.05.2017 в 20:31