Хора я ми кажете кода за upload image?

User avatar
Shorter
Турист
Турист
Posts: 203
Joined: Sun Jan 08, 2006 5:16 pm
Contact:

Хора я ми кажете кода за upload image?

Post by Shorter » Sat Apr 15, 2006 7:55 am

Хора я ми кажете кода за upload image? то е пхп,но нищо,ако намерите за хтмл кажете го плс и за пхп става
Image

our
Потребител
Потребител
Posts: 1401
Joined: Sat Oct 01, 2005 4:33 pm
Answers: 17
Location: Горна Оряховица
Contact:

Post by our » Sat Apr 15, 2006 12:27 pm

Code: Select all

 <? 
session_start&#40;&#41;; 
?> 
<head><title>Upload</title> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head> 
<body> 
<?php 
@session_start&#40;&#41;; 
$site_name = $_SERVER&#91;'HTTP_HOST'&#93;; 
$url_dir = "http&#58;//".$_SERVER&#91;'HTTP_HOST'&#93;.dirname&#40;$_SERVER&#91;'PHP_SELF'&#93;&#41;; 
$url_this = "http&#58;//".$_SERVER&#91;'HTTP_HOST'&#93;.$_SERVER&#91;'PHP_SELF'&#93;; 

$upload_dir = "upload/"; 
$upload_url = $url_dir."/upload/"; 
$message =""; 

/************************************************************ 
* Create Upload Directory 
************************************************************/ 
if &#40;!is_dir&#40;"upload"&#41;&#41; &#123; 
if &#40;!mkdir&#40;$upload_dir&#41;&#41; 
die &#40;"upload_files directory doesn't exist and creation failed"&#41;; 
if &#40;!chmod&#40;$upload_dir,0755&#41;&#41; 
die &#40;"change permission to 755 failed."&#41;; 
&#125; 

/************************************************************ 
* Process User's Request 
************************************************************/ 

if &#40;$_REQUEST&#91;del&#93;&#41; &#123; 
print "<script>window.location.href='$url_this?message=deleted successfully'</script>"; 
&#125; 
else if &#40;$_FILES&#91;'userfile'&#93;&#41; &#123; 
$message = do_upload&#40;$upload_dir, $upload_url&#41;; 
print "<script>window.location.href='$url_this?message=$message'</script>"; 
&#125; 
else if &#40;!$_FILES&#91;'userfile'&#93;&#41;; 
else 
$message = "Invalid File Specified."; 

/************************************************************ 
* List Files 
************************************************************/ 
$handle=opendir&#40;$upload_dir&#41;; 
$filelist = ""; 
while &#40;$file = readdir&#40;$handle&#41;&#41; &#123; 
if&#40;!is_dir&#40;$file&#41; && !is_link&#40;$file&#41;&#41; &#123; 
$filelist .= "<br><a href='$upload_dir$file' target=_blank>".$file."</a>"; 

&#125; 
&#125; 

function do_upload&#40;$upload_dir, $upload_url&#41; &#123; 

$temp_name = $_FILES&#91;'userfile'&#93;&#91;'tmp_name'&#93;; 
$file_name = $_FILES&#91;'userfile'&#93;&#91;'name'&#93;; 
$file_type = $_FILES&#91;'userfile'&#93;&#91;'type'&#93;; 
$file_size = $_FILES&#91;'userfile'&#93;&#91;'size'&#93;; 


$result = $_FILES&#91;'userfile'&#93;&#91;'error'&#93;; 
$file_url = $upload_url.$file_name; 
$file_path = $upload_dir.$file_name; 

if&#40;eregi&#40;"&#40;.jpeg|.jpg|.gif|.png&#41;$", $file_name&#41;&#41; 
&#123; 

//File Name Check 
if &#40; $file_name ==""&#41; &#123; 
$message = "Грешно име. Моля прейменувайте файла"; 
return $message; 
&#125; 
//File Size Check 
else if &#40; $file_size > 5368709120&#41; &#123; 
print $file_size; 
$message = "Размера на файла е много голям."; 
return $message; 
&#125; 

&#125; 
else 
&#123; 
$message = "Може да се качват само ,jpeg,jpg,gif,png. Не по-големи от 5Мб."; 
return $message; 
&#125; 


$result = move_uploaded_file&#40;$temp_name, $file_path&#41;; 
if &#40;!chmod&#40;$file_path,0755&#41;&#41; 
$message = "change permission to 755 failed."; 
else 
$message = &#40;$result&#41;?"$file_name&#40;$file_type&#41; е качена успешно." &#58; 
"Нещо е грешно при ъплода."; 

return $message; 
&#125; 

?> 
<table style="width&#58; 40%" align="center" valign="top"><tr><td align="center"> 
<img src="logo_phpBB2.gif"/></td></tr> 
<tr> 
<td><br> 
<div align="center" style="font-size&#58; 19px; font-weight&#58; bold"> 
</table> 
<body bgcolor="#667987"><center> 
<font color=red><?=$_REQUEST&#91;message&#93;?></font> 
<br> 
<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post"> 
Качи фаил&#58; <input type="file" id="userfile" name="userfile"> 
<input type="submit" name="upload" value="Upload"> 
</form> 

<br> 
Максималната големина на картинката е 5Мб.<br> 
<a href="http&#58;//85.217.144.252/upload.bgnet.com/upload">До сега потребителите ни са качили следните картинки</a><br> 
<b>При повреждане или изгубване на файловете ви, BG NET НЕ носи никаква отговорност!</b> 
</center> 

<? 
if &#40;$_REQUEST&#91;debug&#93;==1&#41; print "------------------Debugging Info----------------<br>"; 
if &#40;$_REQUEST&#91;debug&#93;==1&#41; print "site=$site_name<br>dir=$url_dir<br>url=$url_this<br>"; 
if &#40;$_REQUEST&#91;debug&#93;==1&#41; print "upload dir=$upload_dir<br>upload url=$upload_url<br>"; 
?> 
<table align="center"><tr><td align="center"> 
Благодарим Ви, че използвате BG NET сървъра</td></tr> 
</table> 
</body> 
Само си промени текстовете. Могат да се качват само картинки и то с определена големина ;').

User avatar
Slavnell
Нов
Нов
Posts: 2
Joined: Fri Apr 14, 2006 5:48 pm

Post by Slavnell » Sat Apr 15, 2006 5:21 pm

Благодаря :)

our
Потребител
Потребител
Posts: 1401
Joined: Sat Oct 01, 2005 4:33 pm
Answers: 17
Location: Горна Оряховица
Contact:

Post by our » Sat Apr 15, 2006 5:24 pm

Моля, моля.
Покажи после какво е станало ;')

User avatar
Slavnell
Нов
Нов
Posts: 2
Joined: Fri Apr 14, 2006 5:48 pm

Post by Slavnell » Sat Apr 15, 2006 5:27 pm

Нещо не става. :cry:

Admin
Site Admin
Site Admin
Posts: 4
Joined: Thu Jan 01, 1970 12:00 am
Answers: 224

Post by Admin » Sat Apr 15, 2006 7:28 pm


our
Потребител
Потребител
Posts: 1401
Joined: Sat Oct 01, 2005 4:33 pm
Answers: 17
Location: Горна Оряховица
Contact:

Post by our » Sat Apr 15, 2006 7:32 pm

Slavnell wrote:Нещо не става. :cry:
Работи 10000000000000000000000000% :) Кажи къде точно ти е проблема ;)

User avatar
Slavnell
Нов
Нов
Posts: 2
Joined: Fri Apr 14, 2006 5:48 pm

Post by Slavnell » Sun Apr 16, 2006 9:46 am

Не знам, но излиза само текст.

User avatar
staf
Шаман
Шаман
Posts: 4254
Joined: Sun Sep 25, 2005 10:14 pm
Answers: 9

Post by staf » Sun Apr 16, 2006 10:00 am

Сигурно сървара ти не подържа пхп

our
Потребител
Потребител
Posts: 1401
Joined: Sat Oct 01, 2005 4:33 pm
Answers: 17
Location: Горна Оряховица
Contact:

Post by our » Sun Apr 16, 2006 11:11 am

Къде го качваш ? Хит бг ? :)

Post Reply