- Rendkívül ütőképesnek tűnik az újragondolt Apple tv
- Miniképernyős, VIA-s Epomaker billentyűzet jött a kábelmentes szegmensbe
- Fujifilm X
- Multimédiás / PC-s hangfalszettek (2.0, 2.1, 5.1)
- HTPC (házimozi PC) topik
- Melyik tápegységet vegyem?
- Hobby elektronika
- NVIDIA GeForce RTX 4060 / 4070 S/Ti/TiS (AD104/103)
- Milyen TV-t vegyek?
- Milyen videókártyát?
Hirdetés
-
A Video AI lehet a One UI 6.1.1 ütőkártyája
ma Vagy hogy fogja a mesterséges intelligencia manipulálni a mozgóképeket?
-
Lenovo Essential Wireless Combo
lo Lehet-e egy billentyűzet karcsú, elegáns és különleges? A Lenovo bebizonyította, hogy igen, de bosszantó is :)
-
VR játék lesz az Alien: Rogue Incursion
gp Az év végén érkező program PC-re, Meta Quest 3-ra és PlayStation VR2-re érkezik a tervek szerint.
Új hozzászólás Aktív témák
-
QuippeR
tag
válasz Inv1sus #1071 üzenetére
Ha esetleg még nem ugrott az ötösöd, akkor segítek:
<%@ WebHandler Language="C#" Class="FileStream" %>
using System;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// Reponsible for flushing out the file from the database to the user.
/// </summary>
public class FileStream : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
// get the file id
string fileId = context.Request.QueryString["file"];
using (SqlCommand command = new SqlCommand())
{
// get the file from database
command.Connection = new SqlConnection("connectionstring");
command.CommandText = "SELECT * FROM files where file_id = @FileId";
command.Parameters.AddWithValue("@FileId", fileId);
command.Connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
// flush out the binary data to the user
context.Response.Clear();
context.Response.ContentType = (string) reader["file_type"];
context.Response.AddHeader("Content-Disposition", String.Format("inline;filename={0};", reader["file_name"].ToString()));
context.Response.AddHeader("Content-Length", reader["file_size"].ToString());
context.Response.BinaryWrite((byte[]) reader["file_content"]);
context.Response.End();
}
}
}
public bool IsReusable
{
get
{
return false;
}
}
}Ezt mentsd le egy FileStream.ashx nevű fájlba. A lényege, hogy az url-ben megadod a fájlt id-jét például így: http://localhost/FileStream.ashx?file=4. Az adatbázisban persze a megfelelő adatoknak (file_name, file_size, file_type, file_content) benne kell lennie ehhez.
A feltöltésnél így tudod kiszedni ezeket az értékeket egy fuNewUpload nevű FileUpload controlból:
string filename = fuNewUpload.PostedFile.FileName.Substring(fuNewUpload.PostedFile.FileName.LastIndexOf('\\') + 1);
string filetype = fuNewUpload.PostedFile.ContentType;
int filesize = fuNewUpload.PostedFile.ContentLength;
byte[] filecontent = new byte[fuNewUpload.PostedFile.ContentLength];
fuNewUpload.PostedFile.InputStream.Read(filecontent, 0, fuNewUpload.PostedFile.ContentLength);
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Hobby rádiós topik
- Rendkívül ütőképesnek tűnik az újragondolt Apple tv
- Autós topik
- Kodi és kiegészítői magyar nyelvű online tartalmakhoz (Linux, Windows)
- Garmin Forerunner 255 Music - nem csak futóknak
- Miniképernyős, VIA-s Epomaker billentyűzet jött a kábelmentes szegmensbe
- Kínai, és egyéb olcsó órák topikja
- Formula-1
- Fujifilm X
- iPhone topik
- További aktív témák...
- Creative Hybrid Pro Classic (Egyszer kipróbált, garanciális)
- iPhone 15 Pro 128gb Natúr Titanium, bontatlan, független
- ÚJ Apple Watch Ultra 2 GPS + Cellular 49mm - titántok, alpesi szíj
- 8/16GB memoriák
- APPLE MacBook Air 2020 13" Retina - M1 / 8GB / 256 GB SSD / MAGYAR / 96% akku, 81 ciklus / Garancia