Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Would like to format uploaded files in a table...

New Here ,
Jun 19, 2009 Jun 19, 2009

File NameUploadedFile GroupDownload
Presentation.ppt12/12/2012Company Presentations-Download Button Here-
Presentation 2.ppt1/1/2013Company Presentations-Download Button Here-
Earnings.ppt2/12/2013Company Presentations-Download Button Here-
Our Security.ppt4/14/2013Company Presentations-Download Button Here-

Hello,

I have created a PHP script very similar to this one:

<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

And would like to display all of the uploaded files in a table with basic information about them [EX: Title] and a download link...

Although not a neccesity, I would like the table to alternate colors between files :]

: Look at the top of the page for something of an example....

[I know the file types do not match :]      ]

If you know anything that could help me with this, please post it :]

Thank You

TOPICS
Server side applications
909
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 20, 2009 Jun 20, 2009

I think I know how it can be done, I just don't know how to do it....

1. The PHP Script Runs and Adds the File...

2. Then a second script runs when it is sent the url of the file....

3. The second script gets the name of the file, the time the script runs [and Date], gets the folder name, and creates a download button.....

AND FINALLY: Creates the table

So what I have not added is the extra lines of code in the script to send the info, and the second... "Writing" script

Example:

File name: Presentation.ppt

URL [When the first script runs]

http://www.website.com/page/upload/Presentation.ppt

Time Uploaded: 12:34 1/1/2010

Second Script output:

File NameUploadedFolderDOWNLOAD
Presentation.ppt12:34   1/1/2010upload-Download Button Here-


Is there a way to do this??

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 20, 2009 Jun 20, 2009

Please post all PHP and server-side related questions in the correct forum: Dreamweaver Application Development, where your thread has now been moved.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 20, 2009 Jun 20, 2009

Ok, Thanks... Well now, my forum/thread is here...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 21, 2009 Jun 21, 2009

Hey, I think this website will help u regarding to download link that u wanna try to achieve. You can look at HERE

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 21, 2009 Jun 21, 2009

If you simply want to display the file(s) uploaded on this occasion, it's quite simple. Just store the details of the upload when you call move_uploaded_file():

{
  move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
  $filename = $_FILES["file"]["name"];
  $uploaded = date('H:i n/j/Y');
  $url = "http://www.example.com/upload/" . $_FILES["file"]["name"];
}

You can then use $filename, $uploaded, and $url to create your table.

Or do you want a list of all files that have been uploaded so far?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2009 Jun 21, 2009

I want to show all of the files.... I had an Idea, I can just store the names, url, and etc. in an XML file and create a table that pulls that info, would this work....?

Thank You

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2009 Jun 22, 2009
LATEST

If all the files are in the same folder, you can use PHP's file system functions to get the names of the files and the time they were created. If your server runs PHP 5.2, you can do this with very little code using the DirectoryIterator. With an older version of PHP, you can use scandir() to get the filenames (still requires a minimum of PHP 5, but the manual page also shows how to do it with PHP 4).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines