Başlangıç

Flash diskiniz Dosya veya dizin bozuk ve okunamaz durumda hatası verirse

Yorum bırakın


Windowsta çalıştır kısmına cmd yazın ve yönetici olacak çalıştırın. (Yani komut istemine geçin.) Düzenlemek istediğiniz bölüm hangisi ise chkdsk/r g: komutunu çalıştırın. g: flash diskin bulunduğu bölüme göre değişebilir. Daha sonra flash diski biçimlendirip kullanabilirsiniz.

Jquery ve Asp.NET Resim Upload (WUC (Web User Control) ve Web Servisi Kullanarak)

Yorum bırakın


Resimlerle sırası ile anlatalım.resimupload_wuc_ws_1resimupload_wuc_ws_2resimupload_wuc_ws_3resimupload_wuc_ws_4resimupload_wuc_ws_5resimupload_wuc_ws_6resimupload_wuc_ws_7resimupload_wuc_ws_8resimupload_wuc_ws_9resimupload_wuc_ws_10resimupload_wuc_ws_11resimupload_wuc_ws_12resimupload_wuc_ws_13resimupload_wuc_ws_14resimupload_wuc_ws_15resimupload_wuc_ws_16resimupload_wuc_ws_17resimupload_wuc_ws_18resimupload_wuc_ws_19resimupload_wuc_ws_20resimupload_wuc_ws_21

  • resimyukle.aspx

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”resimyukle.aspx.cs” Inherits=”resimyukle” %>

<%@ Register Src=”~/BasicKontrols/wuc_resimyukle.ascx” TagPrefix=”uc1″ TagName=”wuc_resimyukle” %>
<!DOCTYPE html>

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head runat=”server”>
<title></title>
http://Scripts/jquery-2.1.3.min.js
</head>
<body>
<form id=”form1″ runat=”server”>

</form>
</body>
</html>

  • wuc_resimyukle.ascx

<%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”wuc_resimyukle.ascx.cs” Inherits=”BasicKontrols_wuc_resimyukle” %>

function dosyayukle() {
var value = $(“#FileUpload1″).val();
if (value != ”) {
$(“#form1″).submit();
}
};

<asp:Panel ID=”Pnlfileupload” runat=”server” Width=”253px”>
<asp:FileUpload ID=”FileUpload1″ runat=”server” ClientIDMode=”Static” onchange=”dosyayukle()”/>
</asp:Panel>
<asp:Panel ID=”Pnlfilesonuc” runat=”server” Height=”125px” Width=”172px”>
<asp:Image ID=”Imageyuklenen” runat=”server” Height=”126px” Width=”169px” />
<br />
</asp:Panel>

  • wuc_resimyukle.ascx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class BasicKontrols_wuc_resimyukle : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
var resimservisiCagir = new WSResim_Servisi();//oluşan servisi çağırma
if (!IsPostBack || FileUpload1.PostedFile == null)
{
Session[“yukoncekiresim”] = null;
Pnlfilesonuc.Visible = false;
Pnlfileupload.Visible = true;
return;
}
else
{
Pnlfilesonuc.Visible = true;
Pnlfileupload.Visible = true;

}

if (FileUpload1.PostedFile.FileName.Length <= 0) return;
if (resimservisiCagir.uzantiboyutkontrol(FileUpload1.PostedFile) != true) return;//serviste resim işlemlerini yap

//FileUpload1.SaveAs(Server.MapPath(“~/images/”) + FileUpload1.PostedFile.FileName);
//Label1.Text = FileUpload1.PostedFile.FileName + ” yüklendi..”;
Response.Write(Session[“yukoncekiresim”].ToString());
Imageyuklenen.ImageUrl = Session[“yukoncekiresim”].ToString();
}
}

  • WSResim_Servisi.cs

using System;
using System.Activities.Expressions;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for WSResim_Servisi
/// </summary>
[WebService(Namespace = “http://tempuri.org/&#8221;)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WSResim_Servisi : System.Web.Services.WebService {

public WSResim_Servisi () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld() {
return “Hello World”;
}
public bool uzantiboyutkontrol(HttpPostedFile gelendosya)
{
/*if (Session[“yukoncekiresim”] != null)
{
FileInfo IlkResimDosyasi = new FileInfo(HttpContext.Current.Server.MapPath(Session[“yukoncekiresim”].ToString()));
IlkResimDosyasi.Delete();
}*/
string[] dosyaturleri = { “image/jpg”, “image/png”, “image/gif”, “image/jpeg” };
if (!dosyaturleri.Contains(gelendosya.ContentType)) return false;//resim dosyası uzantı kontrol
int dosyaboyutu = gelendosya.ContentLength / 1024;
if (gelendosya.ContentLength > 0 && dosyaboyutu <= 500) //yüklenen dosya boyutu 500 kilobayta kadar kontrol
{
Random rstgele = new Random();
string ResimUzantisi = Path.GetExtension(gelendosya.FileName);
string ResimAdi = gelendosya.FileName;//gelen dosya adını alma
int resimBoyutu = 800;//hedef genişlik, yükseklik ayarı genişliğe göre otomatik
int resimaduz = gelendosya.FileName.Length;
resimaduz -= 4;
ResimAdi = ResimAdi.Substring(0, resimaduz);//resim adındaki uzantı ve noktasız olarak okuma
ResimAdi += rstgele.Next(99999999, 999999999);//yüklenen dosyaya yeni isimverme
System.Drawing.Image yuklenenFoto = null;
yuklenenFoto = System.Drawing.Image.FromStream(gelendosya.InputStream);

KucukBoyut(yuklenenFoto, resimBoyutu, ResimAdi);//istenen işlemler için diğer fonksiyonu çağır
return dosyaturleri.Contains(gelendosya.ContentType);
}
return false;
}
public void KucukBoyut(System.Drawing.Image yuklenenFoto, int resimBoyutu, string resimIsmi)
{
Bitmap islenmisFoto = null;
Graphics grafikNesnesi = null;
int hedeflenenGenislik = resimBoyutu;
int hedeflenenYukseklik = resimBoyutu;
int yeni_gen, yeni_yuk;
yeni_yuk = (int)Math.Round(((float)yuklenenFoto.Height * (float)resimBoyutu) / (float)yuklenenFoto.Width);
yeni_gen = hedeflenenGenislik;
hedeflenenYukseklik = yeni_yuk;
yeni_gen = yeni_gen > hedeflenenGenislik ? hedeflenenGenislik : yeni_gen;
yeni_yuk = yeni_yuk > hedeflenenYukseklik ? hedeflenenYukseklik : yeni_yuk;
//gönderilen genişliğe göre yükseklik ayarının otomatik olarak belirlenmesi
islenmisFoto = new Bitmap(hedeflenenGenislik, hedeflenenYukseklik);
grafikNesnesi = Graphics.FromImage(islenmisFoto);
grafikNesnesi.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, hedeflenenGenislik, hedeflenenYukseklik));
int x = (hedeflenenGenislik – yeni_gen) / 2;
int y = (hedeflenenYukseklik – yeni_yuk) / 2;
grafikNesnesi.SmoothingMode = SmoothingMode.HighQuality;
grafikNesnesi.CompositingQuality = CompositingQuality.HighQuality;
grafikNesnesi.InterpolationMode = InterpolationMode.Default;
ImageCodecInfo codec = ImageCodecInfo.GetImageEncoders()[1];
EncoderParameters eParams = new EncoderParameters(1);
eParams.Param[0] = new EncoderParameter(Encoder.Quality, 95L);
grafikNesnesi.DrawImage(yuklenenFoto, x, y, yeni_gen, yeni_yuk);
islenmisFoto.Save(HttpContext.Current.Server.MapPath(“~/images/” + resimIsmi + “.jpg”), codec, eParams);
//Son olarak resmimizi resimler klasörüne kaydettik.bu alana uye klasörünüde ekle
Session[“yukoncekiresim”] = “~/images/” + resimIsmi + “.jpg”;
/*
*
* Klasor oluşturmak için ?
if (!Directory.Exists(HttpContext.Current.Server.MapPath(“~/klasoradi”)))
Directory.CreateDirectory(HttpContext.Current.Server.MapPath(“~/klasoradi”));
Klasor silmek için ?
if (Directory.Exists(HttpContext.Current.Server.MapPath(“~/klasoradi”)))
Directory.Delete(HttpContext.Current.Server.MapPath(“~/klasoradi”));*/
}

}

Bir sonraki konuda aynı web servisini kullanarak çoklu resim yükleme yapacağız.

PCI Guru

A common sense approach to achieving PCI compliance and retaining your sanity

Penetration Testing Lab

Offensive Techniques & Methodologies

Bana Python Anlat

meslek lisesi ders notları