Hello Everyone, I was hoping you all would be so kind and help layout some steps for me in a little project I am undertaking. Basically I want a secretary to be able to upload a file (pdf document) after that file is uploaded I want it to automatically create a link to the file on our website. This will be used to make my job easier as I won't have to go in and add HTML code every week when a new board meeting agenda is published along with the minutes. Could you guys please offer me some advice on how to go about this? It would be a great help. Thank you!
Hi Analytst101, A local web developer should be able to implement this solution for you in under a day's work. Otherwise I suggest Google! Cheers, Le-roy Staines
Put this together... Thank you for the advice Leroy! Google has come to the rescue so far this is what I have come up with: I have a webform to upload files with the following code: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><!-- Insert your title here --></title> </head> <body> <form enctype="multipart/form-data" action="upload.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> Choose a file to upload: <input name="uploaded_file" type="file" /> <input type="submit" value="Upload" /> </form> </body> </html> and the corresponding php file looks like this (NOTE this code is only for handling the upload process for PDF documents): <?php if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "pdf") && ($_FILES["uploaded_file"]["type"] == "application/pdf") && ($_FILES["uploaded_file"]["size"] < 4550000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'www.csustan.edu/asi-usu/Invoices/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { echo "It's done! The file has been saved as: ".$newname; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only .pdf images are accepted for upload"; } } else { echo "Error: No file uploaded"; } $varname = $_POST[$newname]; echo "<SCRIPT LANGUAGE='javascript'>refreshParent();</SCRIPT>"; ?> ?> once the pdf file is uploaded to the desired directory, the following php code, placed in a separate file will display the contents of the desired directory with clickable links to the files themselves: <?php if ($handle = opendir('Invoices/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<a href=\"Invoices/".$file."\">".$file."</a><br />"; } } closedir($handle); } ?> my new question is, is it possible to list the files in order based on something like the date uploaded? or in alphabetical order? Thanks for all your feedback!
Look up: http://www.php.net/manual/en/function.array-multisort.php Failing that look up quick sort and bubble sort algorithms. You also need to make sure that you check the files you are accepting in the upload only have one file extension. For example test.php.pdf will be accepted and can be read as either a PHP or pdf file.