Jump to content


Photo

Upload Simples Em .net


  • Faça o login para participar
12 replies to this topic

#1 wozniak

wozniak

    Arquiteto de software

  • Usuários
  • 578 posts
  • Sexo:Masculino
  • Localidade:Rio de Janeiro / RJ

Posted 09/12/2003, 16:18

<%@ Import namespace="System.Io"%> 
<html> 

<head> 
<title>Soluções Inteligentes - Upload</title> 
<script language= "VB" runat= "server"> 

Dim savePath As String = "c:\" 
Sub Upload_Click (source As Object, e As EventArgs) 

if Not(uploadedFile Is Nothing) Then 
Try 
Dim postedFile = uploadedFile.PostedFile 
Dim filename As String = Path.GetFileName (postedFile.FileName) 
Dim contentType As String = postedFile.ContentType 
Dim contentLength As Integer = postedFile.ContentLength 
postedFile.SaveAs (savePath & filename) 
message.Text = postedFile.Filename & " uploaded " & _ 
"<br>Formato: " & contentType & _ 
"<br>Tamanho: " & contentLength.ToString() 
Catch exc As Exception 
message.Text = "Erro na Transferência" 
End Try 
End if 
End Sub 
</script> 


<body> 

<form enctype="multipart/form-data" runat="server" id="Form1"> 
Selecione o arquivo a ser transferido: <input id="uploadedFile" type="file" runat="server" name="uploadedFile"> 
<p><input type="button" id="upload" value="Enviar" onserverclick="Upload_Click" runat="server" name="upload"> 
<p> 
<asp:Label id="message" runat="server" /> 
</p> 
</form> 

</body> 

</html>

t+

#2 MACUL

MACUL

    Doutor

  • Usuários
  • 770 posts
  • Sexo:Masculino
  • Localidade:SP

Posted 15/12/2003, 17:41

Que tipo de variável é PATH ?

Funcionou, mas qdo separei o código p/ o .VB deu essa mensagem

Name 'Path' is not declared.

T +
MACUL
*************** M ** A ** C ** U ** L ***************

*************************************************

#3 MACUL

MACUL

    Doutor

  • Usuários
  • 770 posts
  • Sexo:Masculino
  • Localidade:SP

Posted 15/12/2003, 17:47

eu troquei p/

Dim filename As String = System.IO.Path.GetFileName(postedFile.FileName)

e não deu + o alerta

T +
MACUL
*************** M ** A ** C ** U ** L ***************

*************************************************

#4 wozniak

wozniak

    Arquiteto de software

  • Usuários
  • 578 posts
  • Sexo:Masculino
  • Localidade:Rio de Janeiro / RJ

Posted 15/12/2003, 17:49

já tinham me dito sobre esse erro ae, mais seguinte, eu vou dar uma olhada , vou tentar descobrir pq do erro, esse path, é para mapear o endereço do arquivo

t+

#5 _MX_

_MX_

    Conhecimento nunca é demais

  • Usuários
  • 563 posts
  • Sexo:Não informado
  • Localidade:Diadema-sp

Posted 12/09/2004, 20:20

tem certeza que isso é um tutorial??
========================================================
Copiar o bom é melhor que inventar o ruim
========================================================
"O segredo da criatividade é saber esconder suas fontes"
(Einstein)
========================================================

#6 MACUL

MACUL

    Doutor

  • Usuários
  • 770 posts
  • Sexo:Masculino
  • Localidade:SP

Posted 07/05/2005, 10:39

Adaptado de wozniak

********************* UpLoad.aspx ********************************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>UpLoad</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form enctype="multipart/form-data" runat="server" id="Form1">
Selecione o arquivo a ser transferido: <input id="uploadedFile" type="file" runat="server" name="uploadedFile">
<p><input type="button" id="upload" value="Enviar" onserverclick="Upload_Click" runat="server" name="upload">
<p>
<asp:Label id="message" runat="server" />
</p>
</form>
</body>
</html>
********************* UpLoad.aspx ********************************

*****************************************************************
*****************************************************************

********************* UpLoad.aspx.vb ******************************
Dim savePath As String = "c:\"
Sub Upload_Click(ByVal source As Object, ByVal e As EventArgs)

If Not (uploadedFile Is Nothing) Then
Try

Dim postedFile = uploadedFile.PostedFile
Dim filename As String = System.IO.Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Dim contentLength As Integer = postedFile.ContentLength
postedFile.SaveAs(savePath & filename)
message.Text = postedFile.Filename & " uploaded " & _
"<br>Formato: " & contentType & _
"<br>Tamanho: " & contentLength.ToString()
Catch exc As Exception
message.Text = "Erro na Transferência"
End Try
End If
End Sub

********************* UpLoad.aspx.vb ******************************

*************** M ** A ** C ** U ** L ***************

*************************************************

#7 MACUL

MACUL

    Doutor

  • Usuários
  • 770 posts
  • Sexo:Masculino
  • Localidade:SP

Posted 07/05/2005, 10:39

http://msdn.microsof...edfiletopic.asp

em C# RETIRADO DE

http://www.developer...px?ArticleID=13

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<script language="C#" runat="Server">
void btnUpload_Click(object sender,EventArgs e)
{
if (txtUpload.PostedFile !=null)
{
string FileName = txtUpload.PostedFile.FileName.Substring
(txtUpload.PostedFile.FileName.LastIndexOf("\\") + 1);
int FileSize = txtUpload.PostedFile.ContentLength;
string FileType = txtUpload.PostedFile.ContentType;
if (FileSize <= 0)
Response.Write(" <font color='Red'>Upload failed </font>");
else
{
txtUpload.PostedFile.SaveAs(Server.MapPath(".\\" + FileName));
Response.Write("File uploaded successfully");
Response.Write("<BR>Details");
Response.Write("<BR>File Name: " + FileName);
Response.Write("<BR>File Type: " + FileType);
Response.Write("<BR>File Size: " + FileSize.ToString()");
}
}
}
</script>
<html>
<head>
<title>Upload example</title>
</head>
<body MS_POSITIONING="GridLayout">
<form id="frmUpload" name="frmUpload" method="post"
enctype="multipart/form-data" runat="server">
<TABLE align="center">
<TR>
<TD>
File upload
<br>
<input type="file" id="txtUpload"
name="txtUpload" runat="server"/>
</TD>
</TR>
<TR>
<TD align="center">
<input type="button" value="Upload" runat="server"
id="btnUpload" onserverclick="btnUpload_Click"/>
</TD>
</TR>
</TABLE>
</form>
</body>
</html>
*************** M ** A ** C ** U ** L ***************

*************************************************

#8 MACUL

MACUL

    Doutor

  • Usuários
  • 770 posts
  • Sexo:Masculino
  • Localidade:SP

Posted 07/05/2005, 10:40

http://www.brinkster...ippet.aspx?n234
http://p2p.wrox.com/...p?TOPIC_ID=2085


<%@ Page debug="true" %>

<script language="c#" runat="server">

void Page_Load(Object sender, EventArgs e)
{
if (Page.IsPostBack)
{
SaveImages();
}
}

System.Boolean SaveImages()
{
System.Web.HttpFileCollection colFiles = System.Web.HttpContext.Current.Request.Files;
System.Text.StringBuilder strMessage;
strMessage = new System.Text.StringBuilder("Files Uploaded:<br><br>");
System.Int32 intFileCntr;

try
{

for (intFileCntr = 0; intFileCntr < colFiles.Count; intFileCntr++)
{

System.Web.HttpPostedFile objCurrentFile = colFiles.Get(intFileCntr);
System.String strCurrentFileName;
System.String strCurrentFileExtension;

strCurrentFileName = System.IO.Path.GetFileName(objCurrentFile.FileName);

if(strCurrentFileName != "")
{

strCurrentFileExtension = System.IO.Path.GetExtension(strCurrentFileName);

if (strCurrentFileExtension == ".gif" || strCurrentFileExtension == ".jpg")
{

objCurrentFile.SaveAs("\\\\premfsx\\sites\\premiumx\\xxxxxxxx\\database\\images\\" + strCurrentFileName);

strMessage.Append(strCurrentFileName + " successfully uploaded.<BR>");
}
else
{
strMessage.Append(strCurrentFileName + " <font color='red'>failed!! Only .gif and .jpg images allowed!</font> <BR>");
}
}
}

Label1.Text = strMessage.ToString();
return true;
}
catch (System.Exception Ex)
{
Label1.Text = Ex.Message;
return false;
}
}

</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>::: UPLOAD SAMPLE ::: </title>
</HEAD>
<body>
<center>
<form id="UPLOAD" method="post" runat="server" enctype="multipart/form-data">
<h3>Multiple File Upload Example</h3>
<P>
<INPUT type="file" runat="server" size="50" ID="File1" NAME="File1"></P>
<P>
<INPUT type="file" runat="server" size="50" ID="File2" NAME="File2"></P>
<P>
<INPUT type="file" runat="server" size="50" ID="File3" NAME="File3"></P>
<P>
<INPUT type="file" runat="server" size="50" ID="File4" NAME="File4"></P>
<P>
<INPUT type="file" runat="server" size="50" ID="File5" NAME="File5"></P>
<P><STRONG>:: </STRONG>
<asp:LinkButton id="LinkButton1" runat="server" Font-Names="Verdana" Font-Bold="True" Font-Size="XX-Small">Upload Images</asp:LinkButton> <STRONG>::
</STRONG> <A href="java script:document.forms[0].reset()" id="LinkButton2" style="FONT-WEIGHT:bold;FONT-SIZE:xx-small;FONT-FAMILY:verdana">
Reset Form</A> <STRONG>::</STRONG></P>
<P>
<asp:Label id="Label1" runat="server" Font-Names="verdana" Font-Bold="True" Font-Size="XX-Small" Width="400px" BorderStyle="None" BorderColor="White"></asp:Label></P>
<P> </P>
</form>
</center>
</body>
</HTML>
*************** M ** A ** C ** U ** L ***************

*************************************************

#9 MACUL

MACUL

    Doutor

  • Usuários
  • 770 posts
  • Sexo:Masculino
  • Localidade:SP

Posted 07/05/2005, 10:40

MULTIPLO UPLOAD EM VB.NET

***************************** .aspx *****************************
<form id="Form1" encType="multipart/form-data" runat="server">
Selecione o arquivo a ser transferido:
<br>
<input id="uploadedFile" type="file" name="uploadedFile" runat="server"><br>
<input id="uploadedFile2" type="file" name="uploadedFile2" runat="server">
<p><input id="upload" type="button" value="Enviar" name="upload" runat="server" onserverclick="Upload_Click">
<p>
<asp:Label id="message" runat="server" /></p>
</form>
***************************** .aspx.VB *****************************
Dim savePath As String = "c:\"
Sub Upload_Click(ByVal source As Object, ByVal e As EventArgs)

Dim Loop1 As Integer
Dim TempFileName As String
Dim MyFileCollection As HttpFileCollection = Request.Files

Dim PosFinal As Integer
Dim NomeRvs As String
Dim NomeArq As String

For Loop1 = 0 To MyFileCollection.Count - 1
Try
PosFinal = InStr(StrReverse(MyFileCollection(Loop1).FileName), "\")
If PosFinal > 0 Then
'MyFileCollection(Loop1).FileName = "C:\vazio.zip"
'StrReverse() = piz.oizav\
NomeRvs = StrReverse(MyFileCollection(Loop1).FileName)
'vazio.zip
NomeArq = StrReverse(Mid(NomeRvs, 1, PosFinal - 1))
message.Text += "<br><br>Upload de " & NomeArq

'c:\Vazip.zip
TempFileName = savePath & NomeArq
'Salva o Arquivo
MyFileCollection(Loop1).SaveAs(TempFileName)
End If
Catch exc As Exception
message.Text = "Erro na Transferência"
End Try
Next Loop1

End Sub
*************** M ** A ** C ** U ** L ***************

*************************************************

#10 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 11724 posts

Posted 23/09/2017, 09:13

Cephalexin And Mao Inhibitors online pharmacy Vente De Viagra Sans Ordonnance Discount On Plavix Sarafem And Weight Gain generic cialis Tadalafil Cheapest Price
Comprare Il Viagra cialis Propecia Cipla Canadian
Viagra Y Ciclismo
Viagra Nur Auf Rezept <a href=http://cialtobuy.com>cialis</a> Zithromax And Dairy Products
Cialis Prezzo Online cialis Difference Between Penicillin And Amoxicillin
Como Compro Viagra Propecia Antidoping
Propecia Cost Blog <a href=http://cialtobuy.com>cialis</a> Propecia Frontaler Haarausfall
Comprare Viagra In Parafarmacia cialis Nombre Droga Generica Viagra
Online Pharmacy No Rx
Chemical Mechanism Forming Amoxicillin From Benzene <a href=http://cialtobuy.com>cialis</a> Generic Viagra 20 Mg
Cialis 5 Posologia cialis Sunrise Viagra
Viagra Deutschland Kaufen Propecia Canada Pharmacy Online Finasteride Over Night
Levitra Prezzo In Erboristeria <a href=http://cialtobuy.com>buy cialis</a> Buy Cheap Tamoxifen Online

#11 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 11724 posts

Posted 08/10/2017, 12:47

Viagra Kaufen Spanien Bentyl Real No Prescription viagra online pharmacy Pharmacie Priligy
Candian Pharmacy Lasix Pills Viagra Patent Generika Green Kamagra Oral Jelly cialis Cialis Tratamiento Cancer Purchase Viagra Pe
Viagra With Online Consultation generic viagra Domperidone From Sweden Viagra Prix Quebec Posologia Propecia Dia
Finax Generic Propecia Drug Facts kanada levitra bestellen Levitra Generico Farmacias Del Ahorro

#12 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 11724 posts

Posted 26/10/2017, 11:03

Pfizer Viagra For Sale generic viagra Tomar Cialis Es Bueno
Sandoz Amoxicillin Msds cialis Cialis Ou Acheter
Alprostadil Cream cialis viagra levitra kaufen rezeptfrei Baclofene Mal De Tete
Is Cephalexin Penacillin viagra prescription Farmacia Kamagra Francia Get Direct Progesterone Trophigil Online Price

#13 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 11724 posts

Posted 06/11/2017, 10:51

Sildenafil GРÑСÂnstig Online Kaufen Effetti Propecia Foglietto Illustrativo Precios Cialis Lilly levitra and cialis online Finasteride Costi Propecia
Achat De Cialis En Suisse Prix Cialis 20 Orlistat Generique Xenical brand levitra online Costo Levitra Generico
Kamagra Vente En Ligne whoesale levitra pills Amoxicillin Suspension Kids Taste
Kamagra Time To Work cialis Acheter Tadalis Sx France Levitra Informazioni Generic Levitra Paypal
isotretinoin in us mastercard accepted buy vardenafil 40 mg malaysia Achat Pfizer Viagra Amoxicillin 500mg Walmart Proces Cialis Adiccion
Comprar Cialis Generico 20 Mg Cheap Viagra Online Canada Pharmacy Siti Sicuri Per Acquistare Cialis Generico viagra Darunavir Luogo Per Comprare Kamagra Doxycycline Hyclate 100mg Tablet




0 user(s) are reading this topic

0 membro(s), 0 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq