Jump to content

Is it possible to refuse upload in ma server(Apache) upon a deadline i set?


hellboy_matcha

Recommended Posts

I have a database called files, where i use to store the info(path ,fileID ,docName ,uploadDate ,uploadTime ,ReportType ,who)

of the files  uploaded on ma webserver(Apache).

 

Is it possible to implement a coding where if somebody tries to upload a file let's

say after a deadline that i have set (2007/09/24) the file file won't go uploaded but instead a notification message will be sent to user

echo "Sorry you have passes your deadline for submission", is this possible? somebody plz help me. Here is my file_upload code:

 

<?

//database connection

include_once('conf.php');

 

$folder = "C:/Home/Apache/htdocs/Upload/";

 

$ReportType ="Quiz";

$who = "Sergio";

 

$myfile = basename( $_FILES['up']['name']);  //to extract just the name of the file without the directory listing

$today = date("dmYHis");  //system date to comcatinate with microtime for file renaming before saving to the server

 

$var2 = str_replace('.',"",microtime());  //removing the DOT on the microtime(milliseconds)

$var2 = str_replace(' ',"",$var2);  //Replace the empty space separating the microseconds

$var= $today."_".$var2;  //concatenate the system date with the microtime

$hyphen = strrpos($myfile, "'"); //finding the position of the Hyphen on montly reports

if($hyphen === false)

{

$myfile = $myfile;

}

else{

$string ="/'/"; //in order to remove the hyphen in the monthly reports need to define it

$myfile = preg_replace($string, "", $myfile); //replacing the hyphen

}

 

$pos = strrpos($myfile, ".");//finding the position of the DOT(for extension)  on the string of file name to be        uploaded

 

//if the file has no extension then replace the whole name with the new generated date/time number

if ($pos === false)

{

$mystring = $var;

}

//Otherwise there is a file extension then replace whatever that comes before the DOT with the genareted date/time number

else

{

$mystring = substr_replace($myfile, $var, 0, $pos);//Substitute the real name of the file with the newlly generated key from day and mycrotime exclude the file extension

}

 

$file =  $folder . $mystring; //to direct all the uploads to the folder 'uploads'

$mov = move_uploaded_file($_FILES['up']['tmp_name'], $file);

 

if($mov == TRUE)//if(copy($_FILES['up']['tmp_name'], $file))  move_uploaded_file

{

$alias = $myfile;

$today = date("Y/m/d");

$time = date("H:i:s");

$fileID = $mystring;

 

mysql_query("INSERT INTO `files` ( `path`,`fileID` , `docName` , `uploadDate` , `uploadTime`,`ReportType`,`who`)

VALUES ('/Upload/','$fileID', '$alias', '$today', '$time', '$ReportType', '$who')"); //or die("<span class=text-red-bold> Couldn't insert values into the database:<br>" . mysql_error(). "<br>" . mysql_errno()"<br><IMG height=5 src=http://172.24.10.21/images/bull-gris.gif width=5>   <a class=link-blue-bold  class=link-blue-bold href=$fromPage>GO BACK</a>");

echo "<p class=text-grey-bold>The file <span class=text-orange-bold>".  basename( $_FILES['up']['name'])." </span>has been uploaded successfully</p>   <a class=link-blue-bold  href=audit2.php>Upload more </a><br>";

}

 

else{

echo "<p class=text-grey-bold>There was an <span class=text-red-bold>ERROR uploading ".  basename( $_FILES['up']['name']).".</span><br><br>Select a file with size of less than 200MB and<br><br>   <a class=link-blue-bold href=audit2.php>TRY AGAIN!</a><br>";

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.