Jump to content

Sort mapfiles


hesyar

Recommended Posts

Hello,

Can somebody help me!?

I want to show all files in a map and that by name sort
I have got now this one but it doesn't sort:


[table][tr][td]<?php

if (isset($_FILES['datei']) and ! $_FILES['datei']['error'])
{

$filename = $_FILES['datei']['name'];
move_uploaded_file($_FILES['datei']['tmp_name'], $dir."aufgaben/".$filename);

echo "<b>Status:</b> Upload komplett";

} else {

echo "";

}
?>[/td][/tr][/table]


And i want to show in a table column the last 10 uploads please Help Me!!

Can somebody give a exemple?
Link to comment
Share on other sites

Do you want to show all files in a folder (Mappe), sorted by name?

These may help:

http://sg.php.net/manual/en/ref.dir.php
http://sg.php.net/manual/en/function.glob.php

glob() sorts by name already.

And I suggest you change the topic from "Sort mapfiles" to "Sort directory files" or "Sort folder files" :)

Mach Spass :)
Link to comment
Share on other sites

what you could possible do is make it do is add it to the database and tell the query to list by name. I'm hand coding this script so I dont know if it will work 100% or not. Good Luck.

[code]
<?php
mysql_connect("HOST", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE NAME");

$_max_file_size = "20000000";

echo "<form enctype='multipart/form-data' action='?do=upload_do' method='POST'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . $_max_file_size . "' />";
echo "<input name='userfile' type='file'>";
echo "<input type='submit' value='Upload'>";
echo "</form>";

if($_GET['do'] == 'upload_do')
{
$_file_upload_name = $_FILES['userfile']['name'];
$uploadfile = $_user . "/" . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{ header("Location: ?view=files"); }

$_file = $_POST['file'];
$result = mysql_query("INSERT INTO files (file) values ('$_file')");

header("location:?view=files");

else
{
   echo "<b>Could not upload file.</b><br>";
}}


if($_GET['view'] == 'files')
{
$result6e = mysql_query("SELECT * FROM files ORDER BY name") or die(mysql_error());
while($row6e = mysql_fetch_array( $result6e )) {
echo ". $row6e['name'] . "<br />";
}
}
?>
[/code]
Now remember i just coded that so I dont know what bugs it may run into. You are going to have to go through the code and edit it. Now in your database you will have to make a table named "files" and then put in your database information in the first few lines. Thanks. Reply or message me if you have any questions or need help on something. Thanks.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.