انجمن‌های فارس وب

نسخه کامل: طريقه آپلود تصاوير در ASP.Net
شما در حال بازدید از بایگانی ارسال های انجمن هستید این نسخه کامل نیست : برای مشاهده نسخه کامل اینجا کلیک کنید
سلام
در صورت امکان کد های اپلود عکس توضیح دهید(asp VBScript )
فرض کنید که یک دکمه browse جهت انتخاب عکس ویک FieldImage جهت قرار گرفتن عکس داشته باشیم.
از چه کامپوننتی برای Upload استفاده می کنید ؟
اگه از UploadFile استفاده می کنید که در ASP.Net قابل استفاده است کد زیر برای Upload استفاده می شه :

FileUpload2.PostedFile.SaveAs(address File); 

از محیط net. نمی کنم . در سوالم قید کردم .
در مورد کامپوننت های مورد استفاده هم اطلاعی ندارم .
؟؟؟؟
xooker عزیز

برای این کار کامپوننت های متنوعی وجود داره ، به عنوان مثال :

[ جهت مشاهده لينك عضو شويد ! ]

[ جهت مشاهده لينك عضو شويد ! ]

[ جهت مشاهده لينك عضو شويد ! ]

[ جهت مشاهده لينك عضو شويد ! ]

[ جهت مشاهده لينك عضو شويد ! ]

و یا یه جستجو تو سایت [ جهت مشاهده لينك عضو شويد ! ] انجام بده ، نمونه های بسیاری هست .

البته اگه بخوای خودت بنویسی فکر کنم کد زیر کمکت کنه ، البته از activeX استفاده می کنه :

صفحه Html :

<html>
<head>
<title>ASP Upload with Additional Form Parameters</title>
<body>
<h1>ASP Upload with Additional Form Parameters</h1>

<p>Demonstrates how to pass form parameters in addition to uploading a file.
  The ASP code that receives this POST
will use the form parameters for the Subject, From, To, and Body of an email
.  The uploaded file will be attached to the email.</p>

<form method="POST" enctype="multipart/form-data" action
= "http://localhost/aspEmailUpload.asp" >

Subject: <input name="subject" type="text" size=40><br><br>
From Email: <input name="fromAddr" type="text" size=40><br><br>
To Email: <input name="toAddr" type="text" size=40><br><br>

<textarea name="emailBody" rows="6" cols="40">
Type the plain-text body of your email here...
</textarea><br><br>

Add a file attachment to the email:<br>
<input name=attach1 type=file size=20><br><br>

Attachment Filename in Email: <input name="attachFname" type="text" size=40><br><br>

<input type=submit value="Upload and Email">
</form>

</body>
</html>



و کد asp برای upload فایل :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%

'  The Chilkat ASP Upload component is freeware.
'  The UploadRcv object receives uploads in ASP.
'  It can be used to save uploaded files to the web server,
'  or to save directly to memory for immediate access.
'  This example streams an uploaded file into memory.
set receiver = Server.CreateObject("Chilkat.UploadRcv“)

‘  Set a timeout just in case something hangs
‘  This is a 20-second timeout:
receiver.IdleTimeoutMs = 20000

‘  Consume the upload.  Files are streamed to the UploadDir
success = receiver.Consume()

If (success = 1) And (receiver.NumFilesReceived > 0) Then

    ‘ The Chilkat Upload component is freeware.
    ‘ For demonstration purposes, this example receives the upload
    ‘ form params and file and uses the data to send an email.
    ‘ The Chilkat Email component is not freeware.

    ‘  The mailman object is used for sending and receiving email.
    set mailman = Server.CreateObject(”Chilkat.MailMan2“)

    ‘  Any string argument automatically begins the 30-day trial.
    success = mailman.UnlockComponent(”30-day trial”)
    If (success = 1) Then

        ‘  Set the SMTP server.
        mailman.SmtpHost = “smtp.chilkatsoft.com”

        ‘  Set the SMTP login/password (if required)
        mailman.SmtpUsername = “myLogin”
        mailman.SmtpPassword = “myPassword”

        ‘  Create a new email object
        set email = Server.CreateObject(”Chilkat.Email2“)

        ‘ We don’t use Request.Form.  Instead use receiver.GetParam
    ‘ because the receiver object received the HTTP request.
        email.Subject = receiver.GetParam(”subject”)

        Response.Write “Subject: ” & email.Subject & “<p>”

        email.Body = receiver.GetParam(”emailBody”)
        email.From = receiver.GetParam(”fromAddr”)
        email.AddMultipleTo receiver.GetParam(”toAddr”)

        ‘ Add the uploaded file as an attachment:
        email.AddDataAttachment receiver.GetFileData(0),
receiver.GetParam(”attachFname”)

        ‘  Call SendEmail to connect to the SMTP server and send.
        ‘  The connection (i.e. session) to the SMTP server remains
        ‘  open so that subsequent SendEmail calls may use the
        ‘  same connection.
        success = mailman.SendEmail(email)
        If (success = 1) Then
            ‘  Some SMTP servers do not actually send the email until
            ‘  the connection is closed.  In these cases, it is necessary to
            ‘  call CloseSmtpConnection for the mail to be  sent.
            ‘  Most SMTP servers send the email immediately, and it is
            ‘  not required to close the connection.  We’ll close it here
            ‘  for the example:
            success = mailman.CloseSmtpConnection()
            If (success <> 1) Then
                Response.Write “Connection to SMTP server not closed cleanly.” & “<br>”
            End If

            Response.Write “Mail Sent!” & “<br>”
        else
            Response.Write mailman.LastErrorText & “<br>”
        End If

    else
        Response.Write “Component unlock failed”
    end if

else
    Response.Write “Failed to receive upload.”
end if

%>
</body>
</html>



امیدورام به کارت بیاد چشمک

در ضمن یه نمونه خیلی خوب که البته از ActiveX استفاده کرده رو هم از [ جهت مشاهده لينك عضو شويد ! ] می تونی بگیری . خوب ولی چون از ActiveX استفاده کرده شاید بهتر باشه از موارد دیگه استفاده کنی ....

مرجع آدرس ها