проблем с ъплоад скрипт

mute

Registered
понеже нищо неразбирамот пхп а си сложих един ъплоад скрипт и ми дава следната грешка
Код:
Warning: Wrong parameter count for mkdir() in c:\apache\htdocs\exe\uploadexe.php on line 15
upload_files directory doesn't exist and creation failed
значи скрипта си работи на хостинг сървара но от вкащи от apache-то неще.
етого и скрипта:
Код:
<?php 
@session_start(); 
$site_name = $_SERVER['HTTP_HOST']; 
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); 
$url_this =  "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; 

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

/************************************************************ 
 *     Create Upload Directory 
 ************************************************************/ 
if (!is_dir("files")) { 
  if (!mkdir($upload_dir)) 
     die ("upload_files directory doesn't exist and creation failed"); 
  if (!chmod($upload_dir,0755)) 
     die ("change permission to 755 failed."); 
} 

/************************************************************ 
 *     Process User's Request 
 ************************************************************/ 
  
if ($_REQUEST[del])  {    
print "<script>window.location.href='$url_this?message=deleted successfully'</script>"; 
} 
else if ($_FILES['userfile']) { 
  $message = do_upload($upload_dir, $upload_url); 
  print "<script>window.location.href='$url_this?message=$message'</script>"; 
} 
else if (!$_FILES['userfile']); 
else 
   $message = "Invalid File Specified."; 

/************************************************************ 
 *     List Files 
 ************************************************************/ 
$handle=opendir($upload_dir); 
$filelist = ""; 
while ($file = readdir($handle)) { 
   if(!is_dir($file) && !is_link($file)) { 
      $filelist .= "<br><a href='$upload_dir$file'>".$file."</a>"; 

   } 
} 

function do_upload($upload_dir, $upload_url) { 

   $temp_name = $_FILES['userfile']['tmp_name']; 
   $file_name = $_FILES['userfile']['name']; 
   $file_type = $_FILES['userfile']['type']; 
   $file_size = $_FILES['userfile']['size']; 
   $result    = $_FILES['userfile']['error']; 
   $file_url  = $upload_url.$file_name; 
   $file_path = $upload_dir.$file_name; 

   //File Name Check 
    if ( $file_name =="") { 
       $message = "Invalid File Name Specified"; 
       return $message; 
    } 
    //File Size Check 
    else if ( $file_size > 999999999999999999999) { 
       print $file_size; 
        $message = "Размера на файла е много голям."; 
        return $message; 
    } 
    //File Type Check 
    else if ( $file_type == "text/plain" 
         || $file_type == "application/force-download" 
         || $file_type == "application/octet-stream") { 
        $message = "Sorry, You cannot upload any script file" ; 
        return $message; 
    } 

    $result  =  move_uploaded_file($temp_name, $file_path); 
    if (!chmod($file_path,0755)) 
        $message = "change permission to 755 failed."; 
    else 
      $message = ($result)?"$file_name($file_type) uploaded successfully." : 
                "Somthing is wrong with uploading a file."; 

    return $message; 
} 

?> 
<table  style="width: 40%" align="center" valign="top"><tr><td  align="center">
<img src="mute.gif"/></td></tr>
  <tr> 
    <td><br>
<div align="center" style="font-size: 19px; font-weight: bold">
</table>
<body bgcolor="#667987"><center> 
   <font color=red><?=$_REQUEST[message]?></font> 
   <br> 
   <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post"> 
     Качи фаил: <input type="file" id="userfile" name="userfile"> 
     <input type="submit" name="upload" value="Upload"> 
   </form> 
    
   <br> 
   <br><b>До сега потребителите ни са качили следните файлове:</b> 
   <hr style="color:yellow; background-color:black; height:1px;
  margin-right:0; text-align:right; border:0px">
   <?=$filelist?> 
</center>

<? 
if ($_REQUEST[debug]==1) print "------------------Debugging Info----------------<br>"; 
if ($_REQUEST[debug]==1) print "site=$site_name<br>dir=$url_dir<br>url=$url_this<br>"; 
if ($_REQUEST[debug]==1) print "upload dir=$upload_dir<br>upload url=$upload_url<br>"; 
?>
мерси предварително
 
mute каза:
$upload_dir = "files/";
$upload_url = $url_dir."/files/";

Директорията в която качваш files ли се казва?

Виж защо ти работи на линукс хоста а тук неще.
Там доколкото си спомням беше някаква друга директория.
 
проблема е решен. просто саздадох една папка files и всичко стана нормално, ама защо така при хостинга директорията се саздаде сама а на моя компютар трябваше аз да добавя?
 
staf каза:
Как може да се ограничи какви работи се качват формата големина

To е ограничено.
Не дава да качваш скриптове
Код:
 else if ( $file_type == "text/plain" 
         || $file_type == "application/force-download" 
         || $file_type == "application/octet-stream") { 
        $message = "Sorry, You cannot upload any script file" ;

и големината:


Код:
 else if ( $file_size > 999999999999999999999) { 
       print $file_size; 
        $message = "Размера на файла е много голям."; 
        return $message; 
    }



Само дето тука е дадена някаква огромна големина.
Трябва да я намалиш.
 
пак някви грешки дава, май трябва да сменя апачето ...?


Notice: Use of undefined constant del - assumed 'del' in d:\free\test7\uploadfm.php on line 25

Notice: Undefined index: del in d:\free\test7\uploadfm.php on line 25

Notice: Undefined index: userfile in d:\free\test7\uploadfm.php on line 28

Notice: Undefined index: userfile in d:\free\test7\uploadfm.php on line 32





Notice: Use of undefined constant message - assumed 'message' in d:\free\test7\uploadfm.php on line 95

Notice: Undefined index: message in d:\free\test7\uploadfm.php on line 95


Качи фаил:


До сега потребителите ни са качили следните файлове:
--------------------------------------------------------------------------------

558263044335b81d59e89.jpg
br.gif
index1[1].html

Notice: Use of undefined constant debug - assumed 'debug' in d:\free\test7\uploadfm.php on line 110

Notice: Undefined index: debug in d:\free\test7\uploadfm.php on line 110

Notice: Use of undefined constant debug - assumed 'debug' in d:\free\test7\uploadfm.php on line 111

Notice: Undefined index: debug in d:\free\test7\uploadfm.php on line 111

Notice: Use of undefined constant debug - assumed 'debug' in d:\free\test7\uploadfm.php on line 112

Notice: Undefined index: debug in d:\free\test7\uploadfm.php on line 112

Warning: Unknown(): open(C:\www\php\sessiondata\sess_11601355f5b7fd89c38d4b9de1d0fc35, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\www\php\sessiondata) in Unknown on line 0
 
можели да се направи така че всеки фаил които е добавен към списака да се отваря в _blank
 
mute каза:
можели да се направи така че всеки фаил които е добавен към списака да се отваря в _blank

НЕ разбрах.
НАли за Upload скрипт говориме?
 
staf каза:
пак някви грешки дава, май трябва да сменя апачето ...?

Мисля, че просто нищо не се разбира от горните постове.
ЩЕ има урок специално за Upload скрипт обяснен подробно.
 
admin каза:
staf каза:
пак някви грешки дава, май трябва да сменя апачето ...?

Мисля, че просто нищо не се разбира от горните постове.
ЩЕ има урок специално за Upload скрипт обяснен подробно.
имам някои материали за Upload скрипт, ще ги пусна утре
 
да за upload script- говоря. след като качиш фаил тои се записва в листата питам дали неможе като кликнеш върху фаил от листата тои да се отваря в нов прозорец

надявам се този пат стеме разбрали
 
mute каза:
да за upload script- говоря. след като качиш фаил тои се записва в листата питам дали неможе като кликнеш върху фаил от листата тои да се отваря в нов прозорец

надявам се този пат стеме разбрали

ДАй да видя листата че съм забравил какво правихме с теб.
 
Ако горното е файла който ползваш то има само едно малко добавяне.
НАписал съм го в червено:




<?php
@session_start();
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

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

/************************************************************
* Create Upload Directory
************************************************************/
if (!is_dir("files")) {
if (!mkdir($upload_dir))
die ("upload_files directory doesn't exist and creation failed");
if (!chmod($upload_dir,0755))
die ("change permission to 755 failed.");
}

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

if ($_REQUEST[del]) {
print "<script>window.location.href='$url_this?message=deleted successfully'</script>";
}
else if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
print "<script>window.location.href='$url_this?message=$message'</script>";
}
else if (!$_FILES['userfile']);
else
$message = "Invalid File Specified.";

/************************************************************
* List Files
************************************************************/
$handle=opendir($upload_dir);
$filelist = "";
while ($file = readdir($handle)) {
if(!is_dir($file) && !is_link($file)) {
$filelist .= "<br><a href=".$upload_dir$file ." target=_blank>".$file."</a>";

}
}

function do_upload($upload_dir, $upload_url) {

$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;

//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 999999999999999999999) {
print $file_size;
$message = "Размера на файла е много голям.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain"
|| $file_type == "application/force-download"
|| $file_type == "application/octet-stream") {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}

$result = move_uploaded_file($temp_name, $file_path);
if (!chmod($file_path,0755))
$message = "change permission to 755 failed.";
else
$message = ($result)?"$file_name($file_type) uploaded successfully." :
"Somthing is wrong with uploading a file.";

return $message;
}

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

<br>
<br><b>До сега потребителите ни са качили следните файлове:</b>
<hr style="color:yellow; background-color:black; height:1px;
margin-right:0; text-align:right; border:0px">
<?=$filelist?>
</center>

<?
if ($_REQUEST[debug]==1) print "------------------Debugging Info----------------<br>";
if ($_REQUEST[debug]==1) print "site=$site_name<br>dir=$url_dir<br>url=$url_this<br>";
if ($_REQUEST[debug]==1) print "upload dir=$upload_dir<br>upload url=$upload_url<br>";
?>
 
Код:
Parse error: parse error in D:\hamp\xampp\htdocs\fmbg\graf\uploadfm.php on line 44
а това е $filelist .= "<br><a href=".$upload_dir$file ." target=_blank".$file."</a>";
това което ти си променил :(
 
mute каза:
Код:
Parse error: parse error in D:\hamp\xampp\htdocs\fmbg\graf\uploadfm.php on line 44
а това е $filelist .= "<br><a href=".$upload_dir$file ." target=_blank".$file."</a>";
това което ти си променил :(
пробвай така :

$filelist .= "<br><a href='$upload_dir$file'target=_blank>".$file."</a>";
 
mute каза:
Код:
Parse error: parse error in D:\hamp\xampp\htdocs\fmbg\graf\uploadfm.php on line 44
а това е $filelist .= "<br><a href=".$upload_dir$file ." target=_blank".$file."</a>";
това което ти си променил :(

Код:
$filelist = "<br><a href=".$upload_dir$file ." target=_blank".$file."</a>";

без точка след $filelist

Дай истинския код който ползваш сега.
 
и с . става
<?php
@session_start();
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

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

/************************************************************
* Create Upload Directory
************************************************************/
if (!is_dir("files")) {
if (!mkdir($upload_dir))
die ("upload_files directory doesn't exist and creation failed");
if (!chmod($upload_dir,0755))
die ("change permission to 755 failed.");
}

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

if ($_REQUEST[del]) {
print "<script>window.location.href='$url_this?message=deleted successfully'</script>";
}
else if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
print "<script>window.location.href='$url_this?message=$message'</script>";
}
else if (!$_FILES['userfile']);
else
$message = "Invalid File Specified.";

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

}
}

function do_upload($upload_dir, $upload_url) {

$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;

//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 10000) {
print $file_size;
$message = "Размера на файла е много голям.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain"
|| $file_type == "application/force-download"
|| $file_type == "application/octet-stream") {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}

$result = move_uploaded_file($temp_name, $file_path);
if (!chmod($file_path,0755))
$message = "change permission to 755 failed.";
else
$message = ($result)?"$file_name($file_type) uploaded successfully." :
"Somthing is wrong with uploading a file.";

return $message;
}

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

<br>
<br><b>До сега потребителите ни са качили следните файлове:</b>
<hr style="color:yellow; background-color:black; height:1px;
margin-right:0; text-align:right; border:0px">
<?=$filelist?>
</center>

<?
if ($_REQUEST[debug]==1) print "------------------Debugging Info----------------<br>";
if ($_REQUEST[debug]==1) print "site=$site_name<br>dir=$url_dir<br>url=$url_this<br>";
if ($_REQUEST[debug]==1) print "upload dir=$upload_dir<br>upload url=$upload_url<br>";
?>
 
за пореден път благодарности и на двамата :) получисе
а да пита едно скриптче което само да прави списака с фаилове т.е. като това на upload сктипта .слагам го в дадена директория и то ми показва фаиловете по същия като на уплод скрипта
 

Горе