Webmaster Forumu

Geri git   Webmaster Forumu > Webmaster Kaynak Eğitim Tanıtım Hizmet > İnternet Programlama ve Kodlama > ASP .NET

ASP .NET ASP & .NET

Cevapla
 
LinkBack Seçenekler Stil
  #1 (permalink)   iTrader 
Alt 2007-03-18, 21:10
Member
 
Üyelik tarihi: May 2005
Mesajlar: 284
Tecrübe Puanı: 3
iTrader: %0/0
MadDriver is an unknown quantity at this point
Standart URL ile resim dosyasını hosta aktarmak

Merhaba arkdaşlar,
Kendi bilgisayarımdan upload etmek yeride dosyaların adresini vererek sunucuya aktarmak istiyorum.(resim,zip vb dosyalar) Bunun için gerekli asp kod varmı?
Alıntı ile Cevapla

  #2 (permalink)   iTrader 
Alt 2007-03-19, 16:19
webrlis - ait Kullanıcı Resmi (Avatar)
Member
 
Üyelik tarihi: Jul 2006
Mesajlar: 338
Tecrübe Puanı: 2
iTrader: %75/2
webrlis is on a distinguished road
Standart

bunun için asphttp3 bileşenini kullanmanı tavsiye edrim oldukça basit bişekilde resimleri çekebilirsin.
__________________
--------------
Alıntı ile Cevapla

  #3 (permalink)   iTrader 
Alt 2007-03-20, 21:56
Member
 
Üyelik tarihi: May 2005
Mesajlar: 284
Tecrübe Puanı: 3
iTrader: %0/0
MadDriver is an unknown quantity at this point
Standart

Yardımın için teşekkürler. Şöyle bir örnek buldum yapmak isteyenlere yardımcı olabilecek bir kod:
PHP- Kodu:
<%
Set HTTPObj Server.CreateObject("AspHTTP.Conn")
HTTPObj.Url "http://www.microsoft.com/library/images/gifs/toolbar/write.gif"
HTTPObj.SaveFileTo Server.MapPath("resim.jpg")
HTTPObj.GetURL
%> 
asphttp3 bileşenini yüklemek için http://www.serverobjects.com/comp/asphttp3.zip adresini kullanarak indirebilirsiniz. Buradaki dll dosyasını system32 klasörü içerisine atıp izinler bölümüne geliyoruz. Everyone 'a Read&Execute izinin verdikten sonra;
Başlat>Çalıştır
"regsvr32 asphttp.dll" yazıyoruz.(Tırnakları yazmayın)

Bu kadar
Alıntı ile Cevapla

  #4 (permalink)   iTrader 
Alt 2007-03-22, 01:47
yehhucom - ait Kullanıcı Resmi (Avatar)
Senior Member
 
Üyelik tarihi: Mar 2006
Mesajlar: 527
Tecrübe Puanı: 2
iTrader: %96/23
yehhucom is on a distinguished road
Standart

Herhangi bir bileşen yüklemeden hem url hemde pcnizden dosya seçerek upload yapmak için aşağıdakini kullanabilirsiniz.
dosyaların bulunduğu klasöre /upload/ klasörü yaratıp chmod yetkilerini açın.

code.inc.asp dosyasının içine :
Kod:
<%
class multipart_form
	private dict
	private sub Class_Initialize
		set dict = Server.CreateObject("Scripting.Dictionary")
		parse_form_data()
		parse_query_string()
	end sub

	private sub parse_form_data()

		if Request.TotalBytes > 0 then

			dim form_content_type
			form_content_type = Request.ServerVariables("HTTP_CONTENT_TYPE")

			if Split(form_content_type, ";")(0) = "multipart/form-data" then

				dim bin_data
        
				bin_data = Request.BinaryRead(Request.TotalBytes)
        
				dim bin_separator
				bin_separator = MidB(bin_data, 1, InstrB(1, bin_data, ChrB(13))-1)

				dim cur_pos
				cur_pos = 1
				dim sep_length
				sep_length = LenB(bin_separator)
				dim next_pos
				next_pos = sep_length
				dim item_length
				dim item_value

				While next_pos > 0
					dim do_edit
					do_edit = false

					next_pos = InStrB(cur_pos, bin_data, bin_separator)
					item_length = next_pos-cur_pos

					if item_length > 1 then

						item_value = MidB(bin_data, cur_pos, item_length)

						dim prop_beg
						dim prop_end
						dim name
						dim value
    					prop_beg = 1 + InStrB(1, item_value, ChrB(34))
						prop_end = InStrB(prop_beg+0*1, item_value, ChrB(34))

						dim sub_dict
						set sub_dict = Server.CreateObject("Scripting.Dictionary")

						name = bin2text(MidB(item_value, prop_beg, prop_end-prop_beg))

						sub_dict.add "name", name

							if InStrB(1, item_value, text2bin("Content-Type")) then

								if not dict.exists(name) then

									dim filename
									dim content_type
									dim file_length

									prop_beg = 1 + InStrB(prop_end+1, item_value, ChrB(34))
									prop_end = InStrB(prop_beg, item_value, ChrB(34))
									filename = bin2text(MidB(item_value, prop_beg, prop_end-prop_beg))
									sub_dict.add "filename", filename

									prop_beg = 13 + 1 + InStrB(prop_end+1, item_value, text2bin("Content-Type:"))
									prop_end = InStrB(prop_beg, item_value, ChrB(13))
									content_type = bin2text(MidB(item_value, prop_beg, prop_end-prop_beg))
									sub_dict.add "content_type", content_type

									prop_beg = prop_end + 4
									prop_end = item_length
									file_length = prop_end-prop_beg-1
									value = MidB(item_value, prop_beg, file_length)

									sub_dict.add "file_length", file_length

								end if

							else

								prop_beg = InStrB(prop_beg, item_value, ChrB(13)) + 4
								value = bin2text(MidB(item_value, prop_beg, item_length-prop_beg-1))

								if dict.exists(name) then
									value = dict(name).Item("value") & "," & value
									do_edit = true
								end if

							end if

							sub_dict.add "value", value

							if do_edit = true then
								dict.remove name
							end if
							dict.add name, sub_dict

					end if

					cur_pos = next_pos + sep_length

				Wend

			else
				show_error("Wrong Form Content type: must be 'multipart/form-data'!")
			end if

		end if

	end sub

	private sub parse_query_string()
		dim i
		dim sub_dict
		dim query_parts
		query_parts = Split(Request.ServerVariables("QUERY_STRING"), "&")
		For i = 0 to UBound(query_parts)
			dim var_parts
			var_parts = Split(query_parts(i), "=")
			if var_parts(0) <> "" and not dict.exists(var_parts(0)) then
				dim var_val
				set sub_dict = Server.CreateObject("Scripting.Dictionary")
				if ubound(var_parts) > 0 then
					var_val = var_parts(1)
				else
					var_val = ""
				end if
				sub_dict.add "value", var_val
				dict.add var_parts(0), sub_dict
			end if
		Next

	end sub

	private function bin2text(bin_data)
		dim i
		For i = 1 to LenB(bin_data)
		  bin2text = bin2text & chr(AscB(MidB(bin_data,i,1))) 
		Next
	end function

	private function text2bin(text_data)
		dim i
		For i = 1 to Len(text_data)
		  text2bin = text2bin & chrB(AscB(Mid(text_data,i,1)))
		Next
	end function

	private sub show_error(str)
		Response.Write str
	end sub

	public function get_value(name)
		if dict.exists(name) then
			get_value = dict(name).Item("value")
		else
			get_value = ""
		end if
	end function

	public function get_file_path(name)
		if dict.exists(name) then
			get_file_path = dict(name).Item("filename")
		else
			get_file_path = ""
		end if
	end function

	public function get_file_dir(name)
		if dict.exists(name) then
			dim pos
			dim filename
			filename = dict(name).Item("filename")

			if filename = "" then
				get_file_dir = ""
			end if

			pos = InStrRev(filename, "\")
			get_file_dir = Mid(filename, 1, pos)
		else
			get_file_dir = ""
		end if
	end function

	public function get_file_name(name)
		if dict.exists(name) then
			dim pos
			dim filename
			filename = dict(name).Item("filename")

			if filename = "" then
				get_file_name = ""
			end if

			pos = InStrRev(filename, "\")
			get_file_name = Mid(filename, pos+1)
		else
			get_file_name = ""
		end if
	end function

	public function get_content_type(name)
		if dict.exists(name) then
			get_content_type = dict(name).Item("content_type")
		else
			get_content_type = ""
		end if
	end function

	public function get_file_length(name)
		if dict.exists(name) then
			get_file_length = dict(name).Item("file_length")
		else
			get_file_length = 0
		end if
	end function

	public function save_file(name, path)
		if dict.exists(name) and get_file_length(name)>0 then
			dim fso
			set fso = Server.CreateObject("Scripting.FileSystemObject")
			dim fd
'			set fd = fso.CreateTextFile(Server.MapPath(path))
			set fd = fso.CreateTextFile(path)
			dim file_data
			file_data = bin2text(get_value(name))

			fd.Write file_data
			fd.Close

			save_file = True
		else
			save_file = False
		end if
	end function

	public function get_array_of_names(name)
		dim i
		dim value
		value = ""
		dim keys
		keys = dict.keys
			
		for i=0 to dict.count-1
			if instr(1, keys(i), name & "[") = 1 then
				if not value = "" then
					value = value & ","
				end if
				value = value & keys(i)
			end if
		next

		get_array_of_names = Split(value, ",")
	end function

end class
%>

upload.asp dosyasının içine :
Kod:
<!-- #INCLUDE file="code.inc.asp" -->
<%

	dim m_form
	set m_form = new multipart_form

	Response.Write "<b>Values of the variables submitted:</b><br><br>"
	Response.Write "Value of variable comment = " & m_form.get_value("comment") & "<br>"
	Response.Write "Value of variable hidden_field = " & m_form.get_value("hidden_field") & "<br>"
	Response.Write "Value of variable get_var = " & m_form.get_value("get_var") & "<br>"
	Response.Write "Value of variable choices = " & m_form.get_value("choices") & "<br>"


	Response.Write "<br>File uploading:<br>"

	Response.Write "<br>	File #1:<br>"
	Response.Write "Full file path= " & m_form.get_file_path("file2upload[1]") & "<br>"
	Response.Write "Path = " & m_form.get_file_dir("file2upload[1]") & "<br>"
	Response.Write "File name = " & m_form.get_file_name("file2upload[1]") & "<br>"
	Response.Write "Content type of file = " & m_form.get_content_type("file2upload[1]") & "<br>"
	Response.Write "Length of file = " & m_form.get_file_length("file2upload[1]") & "<br>"

	Response.Write "<br>	File #2:<br>"
	Response.Write "Full file path= " & m_form.get_file_path("file2upload[3]") & "<br>"
	Response.Write "Path = " & m_form.get_file_dir("file2upload[3]") & "<br>"
	Response.Write "File name = " & m_form.get_file_name("file2upload[3]") & "<br>"
	Response.Write "Content type of file = " & m_form.get_content_type("file2upload[3]") & "<br>"
	Response.Write "Length of file = " & m_form.get_file_length("file2upload[3]") & "<br>"

	'upload files
	dim key
	dim file_names
	file_names = m_form.get_array_of_names("file2upload")

	dim path2save
	path2save = "/upload/"

	for each key in file_names
		m_form.save_file key, Server.MapPath(path2save & m_form.get_file_name(key))
	Next

%><html>
<body>
<form enctype="multipart/form-data" action="upload.asp?get_var=get_value" method="post">
<input type="hidden" name="hidden_field" value="hidden_value">
<input type="text" name="comment"><br>
<select name="choices" multiple>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
</select><br>
file:<input type="file" name="file2upload[1]"><br>
url:<input type="text" name="file2upload[3]">&nbsp;
<input type="submit" value="Upload">
</form>

</body>
</html>
Alıntı ile Cevapla

Cevapla

Seçenekler
Stil


Benzer Konular
Konu Konuyu Başlatan Forum Cevaplar Son Mesaj
vbullettin forumumu başka siteye aktarmak war Vbulletin VbSEO 7 2006-12-01 08:01
Adsense'de Kazandığımızı Adwords'e Aktarmak wichasha Google Adsense 0 2006-06-15 10:47
Hosta Ödeme advertiser Web Hosting Kurulum Donanım Yazılım 2 2006-04-25 20:44
hosta dışardan resim ekleme yakese Webmaster Genel Konular 6 2006-01-24 20:47
phpBB DB'sini Vbulletin'e aktarmak Parae phpBB 14 2005-07-14 17:54


Bütün Zaman Ayarları WEZ +2 olarak düzenlenmiştir. Şu Anki Saat: 11:09 .


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0

Firefox