Hola que tal,
tengo un problema, a ver... estoy trabajando con c# sobre MySQL y necesito
introducir en un campo "blob" una imagen. (no me vale con disponer de la
ruta tengo que incluirla en la bd)
Entonces tengo el codigo para hacer el upload, pero en este codigo intento
pasarle el byteData que se supone que contiene el "archivo" subido, pero no
hay forma humana de que funcione :(
¿alguien podría ayudarme? Este codigo lo saque de un ejemplo pero no consigo
hacer que funcione ni este ni otros, me tiene que faltar algo que no se de
dnd...
Un saludo y gracias
La función de grabar tiene estos parametros:
public void grabar(string strName, ref byte[] Buffer)
y la llamo pasandole el nombre y el REF byteData
public void btnUpload_Click(object sender, System.EventArgs e)
{
// If no file was uploaded then you probably want to inform the user to
select a file
// before clicking the upload button.
if (filUpload.PostedFile != null)
{
// Get a reference to the uploaded file
HttpPostedFile filPosted = filUpload.PostedFile;
int intFileLength = System.Convert.ToInt32(filPosted.ContentLength);
// Ensure that there were contents to the file. Exit out of the function if
there is no content.
if (intFileLength == 0)
{
return;
}
// This may not be necessary
byte[] byteData = new byte[intFileLength];
filPosted.InputStream.Read(byteData, 0, intFileLength);
}
}
Leer las respuestas