hvorfor vil filnavnet ikke skrives? Simpelt EVT.
Hej jeg har denne php upload script den vil meget gerne oploade og virker godt.. dog vil den ikke skrive filnavnet $_file_name vil inskrives i log filen upload_log.txt:<?php
session_start();
include("database.php");
include("login.php");
if($logged_in){
echo 'Logged in as '.$_SESSION['username'].', <a href="logout.php">logout</a>';
//edit this
$_max_file_size = '5000'; //file size in bytes.
$upload_dir = "files/"; //upload folder..chmod to 777
$_i = "3"; //number of files to upload at one time
//end edit
echo "Maximum file size : " . $_max_file_size/1000 . "KB<br>";
echo "<form enctype='multipart/form-data' action='?do=upload' method='post'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . $_max_file_size , "'>";
echo "Choose your file(s): <br>";
//show number of files to select
For($i=0; $i <= $_i-1;$i++)
{
echo "<input name='file" . $i . "' type='file'><br>";
}
echo "<input type='submit' value='Upload File'>";
echo "</form>";
if($_GET['do'] == 'upload')
{
//upload all the fields until done
For($i=0; $i <= $_i-1; $i++)
{
//create a random number
$_random = rand(1, 1000000);
//file with the upload folder
$target_path = $upload_dir . $_random . basename($_FILES['file' . $i]['name']);
//actual file name with the random number
$_file_name = $_random . basename($_FILES['file' . $i]['name']);
//do not upload the 'left blank' fields
if(basename($_FILES['file' . $i]['name']) != '')
{
if(move_uploaded_file($_FILES['file' . $i]['tmp_name'], $target_path))
{
//uploaded successfuly
$_uploaded=1;
}
else
{
//error uploading
$_error=1;
}
}
else
{
$_check=$_check+1;
}
}
//file(s) did upload
if($_uploaded == '1')
{
$_uploaded=0;
echo "The file(s) have been uploaded.<br>";
}
//file uploaded?
if($_error == '1')
{
$_error=0;
echo "There was an error uploading some of the file(s), please try again! Maybe the file size. Maximum file size is " . $_max_file_size/1000 . "KB<br>";
}
//user selected a file?
if($_check == $_i)
{
$_check=0;
echo "Select a file first than click 'Upload File'<br>";
}}
JEG ER MEGET I TVIVL OM DENNE DEL:
$upload_log_file = "upload_log.txt";
$resource = fopen($upload_log_file,"a");
fwrite($resource, "$_file_name");
fclose($resource);
HERTIL
}else{
echo "Not logged in." ;
displayLogin();
}?>
SOM SAGT VIRKER DEN IKKE, den skriver kun random numre i stil med det her:3453917
:) så spg. er hvad det kan skyldes og hvordan får jeg den sidste del af $_file_name