
<form enctype="multipart/form-data" action="_URL_" method="post"> Send this file: <input name="FILE1" type="file"> <input type="submit" value="Upload"> </form>_URL_ by mělo označovat ASP soubor.
<%
' Variables
' *********
Dim mySmartUpload
Dim intCount
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
' Save the files with their original names in a virtual path of the web server
' ****************************************************************************
intCount = mySmartUpload.Save("Upload")
' sample with a physical path
' intCount = mySmartUpload.Save("c:\temp\")
' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.")
%>
více informací o komponentě aspSmartUpload naleznete na http://www.aspsmart.com/aspSmartUpload/
<%
Dim myMail, Odesilatel, Prijemce, Predmet, TextZpravy, SmtpServer
Set myMail = CreateObject ("CDO.Message")
Odesilatel = "Email@odesilatele.cz"
Prijemce = "Email@prijemce.cz"
Predmet = "Předmět zprávy"
TextZpravy = "Zde vložte tělo zprávy, které chcete odeslat"
SmtpServer = "relay.dialtelecom.cz" '
myMail.Subject = Predmet
myMail.From = Odesilatel
myMail.To = Prijemce
myMail.TextBody = TextZpravy
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SmtpServer
'Server port
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Update
myMail.Send
Set myMail = nothing
%>
<%
Option Explicit
Dim sqlspojeni, SQLServer, Databaze, Login, Heslo
Set sqlspojeni = Server.CreateObject("ADODB.Connection")
SQLServer = "sql.vol.cz,1433"
Databaze = "jmeno_databaze"
Login = "uzivatelske_jmeno"
Heslo = "heslo"
sqlspojeni.Open "Driver={SQL SERVER};Server=" & SQLServer & ";Database=" & Databaze & ";UID=" & Login & ";PWD=" & Heslo
%>
<form enctype="multipart/form-data" action="_URL_" method="post"> Send this file: <input name="userfile" type="file"> <input type="submit" value="Send File"> </form>_URL_ by mělo označovat PHP soubor.
<?php
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
copy($_FILES['userfile']['tmp_name'], "kam/ulozit/nahrany/soubor");
} else {
echo "Possible file upload attack. Filename: " . $_FILES['userfile']['name'];
}
/* ...nebo... */
move_uploaded_file($_FILES['userfile']['tmp_name'], "kam/ulozit/nahrany/soubor");
?>
<?php
mail("rasmus@lerdorf.on.ca", "Můj předmět", "Řádek 1\nŘádek 2\nŘádek 3");
?>
Příklad: Odeslání mailu s extra hlavičkami
<?php
mail("nobody@aol.com", "předmět", $message,
"From: webmaster@$SERVER_NAME\nReply-To: webmaster@$SERVER_NAME\nX-Mailer: PHP/" . phpversion());
?>
Příklad: Odeslání komplexního emailu
<?php /* recipients */ $recipient .= "Mary <mary@u.college.edu>" . ", " ; //všimněte si čárky $recipient .= "Kelly <kelly@u.college.edu> . ", "; $recipient .= "ronabop@php.net"; /* subject */ $subject = "Birthday Reminders for August"; /* message */ $message .= "Následující email obsahuje formátovanou ASCII tabulku\n"; $message .= "Day \t\tMonth \t\tYear\n"; $message .= "3rd \t\tAug \t\t1970\n"; $message .= "17rd\t\tAug \t\t1973\n"; /* můžete přidat signaturu */ $message .= "--\r\n"; //oddělovač signatury $message .= "Birthday reminder copylefted by public domain"; /* dodatečné hlavičky pro chyby, From, cc, bcc, atd */ $headers .= "From: Birthday Reminder <birthday@php.net>\n"; $headers .= "X-Sender: <birthday@php.net>\n"; $headers .= "X-Mailer: PHP\n"; // mailový klient $headers .= "X-Priority: 1\n"; // Urgentní vzkaz! $headers .= "Return-Path: <birthday@php.net>\n"; // Návratová cesta pro chyby /* Pokud chcete poslat HTML email, odkomentujte následující řádek */ // $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; // Mime typ $headers .= "cc:birthdayarchive@php.net\n"; // CC $headers .= "bcc:birthdaycheck@php.net, birthdaygifts@php.net\n"; // BCC /* a teď to odešleme */ mail($recipient, $subject, $message, $headers); ?>
<?php
$server = "sql.vol.cz";
$login = "uziv_jmeno";
$password = "heslo";
$link = mysql_connect($server, $login, $password)
or die("Nelze se připojit");
/* ... váš kód ... */
mysql_close($link);
?>
<?php
function compress($srcName, $dstName)
{
$fp = fopen($srcName, "r");
$data = fread ($fp, filesize($srcName));
fclose($fp);
$zp = gzopen($dstName, "w9");
gzwrite($zp, $data);
gzclose($zp);
}
// Compress a file
compress("data\myfile.dat", "data\myfile.gz");
?>
<?php
// The file
$filename = 'test.jpg';
$percent = 0.5;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagejpeg($image_p, null, 100);
?>