Copy link to clipboard
Copied
| File Name | Uploaded | File Group | Download |
|---|---|---|---|
| Presentation.ppt | 12/12/2012 | Company Presentations | -Download Button Here- |
| Presentation 2.ppt | 1/1/2013 | Company Presentations | -Download Button Here- |
| Earnings.ppt | 2/12/2013 | Company Presentations | -Download Button Here- |
| Our Security.ppt | 4/14/2013 | Company 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
Copy link to clipboard
Copied
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 Name | Uploaded | Folder | DOWNLOAD |
|---|---|---|---|
| Presentation.ppt | 12:34 1/1/2010 | upload | -Download Button Here- |
Is there a way to do this??
Copy link to clipboard
Copied
Please post all PHP and server-side related questions in the correct forum: Dreamweaver Application Development, where your thread has now been moved.
Copy link to clipboard
Copied
Ok, Thanks... Well now, my forum/thread is here...
Copy link to clipboard
Copied
Hey, I think this website will help u regarding to download link that u wanna try to achieve. You can look at HERE
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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).
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more