Ok so i have this code to go through a file and output a table with 3 colums the first is an image the second is the file name without the extention and the third is a checkbox. now what i want the cod eto be able to do is have it so that when a user selects a checkbox he can select what to do with the files (ie. delete or move to pendrive) but i don't know enough about the code to know what i should change
This is the page the user sees information.php
<html>
<head>
<?php
$dirname = "bhi";
$dir = opendir($dirname);
?>
<title>Files inside the folder BHI</title>
</head>
<body>
<h1>Upload a file here</h1>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
echo "<table border=1px>"; //start the table
echo "<form action='move_file.php' method='post' enctype='multipart/form-data'>";
while(($file = readdir($dir)) != false)
{
$folder="bhi";
if(($file != ".") and ($file != ".."))
{
$ending=strrchr($file,'.'); //take the end of the file name and place it into the variable $ending
$page_name=substr($file, 0, strpos($file, ".")); // place the name with out the ending in the variable $page_name
if($ending==".html")
{
$icon= "<img src='icon/ie.png' alt='HTML File' border=none width=25px height=25px>";
}
else if($ending==".png")
{
$icon= "<img src='icon/png.png' alt='PNG Picture' border=none width=25px height=25px>";
}
else if($ending==".jpeg")
{
$icon= "<img src='icon/jpeg.png' alt='JPEG Picture' border=none width=25px height=25px>";
}
else if($ending==".jpg")
{
$icon= "<img src='icon/jpg.png' alt='JPG Picture' border=none width=25px height=25px>";
}
else if($ending==".pdf")
{
$icon= "<img src='icon/pdf.png' alt='Adobe Acrobat Reader File' border=none width=25px height=25px>";
}
else if($ending==".swf")
{
$icon= "<img src='icon/swf.png' alt='SWF File' border=none width=25px height=25px>";
}
else if($ending==".docx")
{
$icon= "<img src='icon/docx.bmp' alt='Microsoft Word 2007 File' border=none width=25px height=25px>";
}
else if($ending==".doc")
{
$icon= "<img src='icon/doc.bmp' alt='Microsoft Word 2003 File' border=none width=25px height=25px>";
}
else if($ending==".gif")
{
$icon= "<img src='icon/gif.png' alt='GIF Picture' border=none width=25px height=25px>";
}
else if($ending==".bmp")
{
$icon= "<img src='icon/bmp.png' alt='BMP Picture' border=none width=25px height=25px>";
}
else if($ending==".ppt")
{
$icon= "<img src='icon/ppt.bmp' alt='Microsoft Power Point Presentation' border=none width=25px height=25px>";
}
else if($ending==".rar")
{
$icon= "<img src='icon/rar.bmp' alt='RAR Compressed File' border=none width=25px height=25px>";
}
else if($ending==".zip")
{
$icon= "<img src='icon/zip.bmp' alt='ZIP Compressed File' border=none width=25px height=25px>";
}
echo "<td><a href='$folder/$file'>$icon</a></td>";
echo "<td><a href='$folder/$file'>$page_name</a></td>";
echo "<td><input type=CHECKBOX name='$page_name$ending' id='file' value='$file'></td></tr>";
}
}
echo "<input type='submit' name='submit' value='Move' />";
echo "</form>";
?>
</body>
</html>
Now here is the file move_file.php
<?php
$folder="bhi_move";
//&& ($_FILES["file"]["size"] < 20000))
// {
if ($_FILES["file"]["error"] > 0)
{
echo "There has been an error this is the Return Code: " . $_FILES["file2"]["error"] . "<br />";
}
else
{
echo "You have successfully moved: " . $_FILES["file"]["name"] . "<br />";
// echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("$folder" . $_FILES["file"]["name"]))
{
echo "<h3>We are sorry the file \"" . $_FILES["file"]["name"] . "\" already exists. </h3>";
}
else
{
$file=$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"],
"$folder/" . $_FILES["file"]["name"]);
echo "Stored in: " . "$folder/" . $_FILES["file"]["name"];
}
}
?>