Code: Select all
mb_strtolower(); In my server haven`t installing liberary GD and no runing upload avatars.
my code upload is:
Code: Select all
elseif ($_GET['act'] == "upload") {
echo <<< KONIEC
<hr>
<center>
<p>
<h2>Dodaj zdjęcie</h2>
<ul class="gallery clearfix">
<li class="extra">
KONIEC;
error_reporting(E_ALL);
// we first include the upload class, as we will need it here to deal with the uploaded file
include('include/class.upload.php');
// retrieve eventual CLI parameters
$cli = (isset($argc) && $argc > 1);
if ($cli) {
if (isset($argv[1])) $_GET['file'] = $argv[1];
if (isset($argv[2])) $_GET['dir'] = $argv[2];
if (isset($argv[3])) $_GET['pics'] = $argv[3];
}
// set variables
$dir_dest = (isset($_GET['dir']) ? $_GET['dir'] : 'test');
$dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest);
if (!$cli) {
}
// we have three forms on the test page, so we redirect accordingly
if ((isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '')) == 'simple') {
// ---------- SIMPLE UPLOAD ----------
// we create an instance of the class, giving as argument the PHP object
// corresponding to the file field from the form
// All the uploads are accessible from the PHP object $_FILES
$handle = new Upload($_FILES['my_field']);
// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)
if ($handle->uploaded) {
// yes, the file is on the server
// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->Process($dir_dest);
function TestProcess(&$handle, $title = 'test', $details='') {
global $dir_pics, $dir_dest;
$unlink = 'test/'. $handle->file_dst_name;
$myid = $_SESSION['id'];
$opis = htmlspecialchars(stripslashes(strip_tags(trim($_POST["opis"]))), ENT_QUOTES);
$handle->Process($dir_dest);
if ($handle->processed) {
unlink("$unlink");
$link = ''.$dir_pics.'/' . $handle->file_dst_name .'';
$addphoto = mysql_query("INSERT INTO photo VALUES('', '$myid', '$link', '$opis')");
echo <<< KONIEC
<br>
<center>
<img src="$link" >
<br>
<br />
</center>
KONIEC;
} else {
echo '<fieldset class="classuploadphp">';
echo ' <legend>' . $title . '</legend>';
echo ' Error: ' . $handle->error . '';
if ($details) echo ' <pre class="code php">' . htmlentities($details) . '</pre>';
echo '</fieldset>';
}
}
if (!file_exists($dir_dest)) mkdir($dir_dest);
// -----------
$handle->image_convert = 'jpg';
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 500;
$handle->image_precrop = 15;
$handle->image_watermark = "watermark_large.png";
$handle->image_watermark_x = 20;
$handle->image_watermark_y = -20;
TestProcess($handle, '15px pre-cropping (before resizing 800 wide), large watermark automatically reduced, position 20 -20', "\$foo->image_convert = 'jpg';\n\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 800;\n\$foo->image_precrop = 15;\n\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_x = 20;\n\$foo->image_watermark_y = -20;");
} else {
// one error occured
echo '<fieldset>';
echo ' <legend>file not uploaded to the wanted location</legend>';
echo ' Error: ' . $handle->error . '';
echo '</fieldset>';
}
// we copy the file a second time
// we delete the temporary files
$handle-> Clean();
} else {
// if we are here, the local file failed for some reasons
echo '<fieldset>';
echo ' <legend>local file error</legend>';
echo ' Error: ' . $handle->error . '';
echo '</fieldset>';
}
echo <<< KONIEC
<li>
</ul>
</p>
</center>
KONIEC;