Pregunta: | 43499 - UPLOAD SIN FORMULARIO |
Autor: | javi juanka |
Hola a todos!!!!!
a ver si alguien me puede echar una mano con esto. necesito saber como puedo coger un archivo de un directorio y subirlo a sql server sin formulario, o sea, que lo haga automáticamente, sin que un usuario tenga que cogerlo mediante formulario. ya lo tengo hecho con formulario y va todo bien, pero necesito que el código lo haga automáticamente. gracias por todo, no he encontrado nada por internet hecho. |
Respuesta: | Cpp |
Hola yo me subo ficheros y me funciona perfectamente. Espero que a tí tambien.
Ya me dirás. !suerte! A través de una pagina asp me he creado un control htm de tipo file: <TR><TD class="texto6" >Fichero</TD> <TD><INPUT class="formulario" id="File1" type="file" name="TbNombreFichero" runat="server"></TD></TR> Protected WithEvents File1 As System.Web.UI.HtmlControls.HtmlInputFile donde capturo a través del botón examinar la ruta del fichero a subir: Dim ruta As String ruta = "C:\intranetdocumentos\noticias\" y luego lo siguiente: If Not (File1.PostedFile Is Nothing) Then Try Dim ficheroEnviado As System.Web.HttpPostedFile = File1.PostedFile Dim nombreFichero As String = System.IO.Path.GetFileName(ficheroEnviado.FileName) Dim tipoFichero As String = ficheroEnviado.ContentType Dim contentlenght As String = ficheroEnviado.ContentLength ' ficheroEnviado.SaveAs(ruta & nombreFichero) ' Lbmensaje.Text = "Fichero: " & nombreFichero & " subido correctamente, a " & DropDownList1.SelectedItem.Text ' Catch ex As Exception Lbmensaje.Text += vbCrLf & "Error al subir el fichero: " & ex.Message End Try Else End If Else Lbmensaje.Text = "Seleccione una ruta." End If |
Respuesta: | charlos jim |
Por medidas de seguridad no es posible inicializar el objeto file (type=file) que es el que necesitarias para ello ya que si se pudiera seria posible robar cualquier fichero de un usuario que navegue por mi pagina. |