Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

Who wants to help me with PHP code?

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

Who wants to help me with PHP code?

Old 07-16-04, 11:49 PM
DVD Talk Hall of Fame
Thread Starter
Join Date: Jul 1999
Location: Texas
Posts: 7,759
Likes: 0
Received 0 Likes on 0 Posts
Who wants to help me with PHP code?

I have no idea how to code anything more advanced than HTML. BUT, I'm trying to do something simple with PHP. I have a script on my web page to upload files to a directory. It works just fine the way it is. I would like to add a link to the file once it is uploaded. Currently it just displays the file, either as text or an image. I want to have the full URL and be able to click on it, as well. For example, if I uploaed DVDTalk.com I would want the URL to look like this:

But I'm inept and can't figure it out. Here is the portion of my script that deals with what happens on the successful upload page (All HTML is cancelled with a space after the opening caret)
// Successful upload!
			print($my_uploader->file['name'] . " was successfully uploaded! < a href=\"" . $_SERVER['PHP_SELF'] . "\">Try Again< /a>< br>");
			// Print all the array details...
			// ...or print the file
			if(stristr($my_uploader->file['type'], "image")) {
				echo "< img src=\"" . $path . $my_uploader->file['name'] . "\" border=\"0\" alt=\"\">";
			} else {
				$fp = fopen($path . $my_uploader->file['name'], "r");
				while(!feof($fp)) {
					$line = fgets($fp, 255);
					echo $line;
				if ($fp) { fclose($fp); }
You can download the full thing here: http://flamingduck.com/images/upload_tool.zip
Thanks in advance for your help!
Old 07-17-04, 09:56 AM
DVD Talk Special Edition
Join Date: Sep 1999
Location: Bristol, CT USA
Posts: 1,861
Likes: 0
Received 0 Likes on 0 Posts
This is how I do it at http://www.danandsherree.com/miscfiles/
PHP Code:
title>danandsherree.comFile Uploads and Listing</title>
link rel="stylesheet" href="/styles.css" type="text/css" />

h1>File Uploads and Listing</h1>

h2>Upload a File</h2>

A file by that name already existsYour file has been renamed to $name.</p>";

// If a file was uploaded, process this stuff.
if (
$_FILES['filename'] != NULL) {

    // put the 
$_FILES array into regular strings to make things easier.
$name = $_FILES['filename']['name'];
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$size = $_FILES['filename']['size'];

    // Acceptable file types
$ftype[0] = "image/jpeg";
$ftype[1] = "image/pjpeg";

    if (in_array(
$type$ftype) && $size <b>Successfully uploaded!</b>";
"<b>filename:</b> $name, <b>type:</b> $type, <b>size:</b> $size bytes";
"URL: <a href=\"$name\" target=\"_blank\">[url]http://www.danandsherree.com/miscfiles/[/url]$name</a></p>";
        } else {
"<p><b>Upload failed!</b> and I don't know why.</p>";
    } else {
"<p class=\"noindent\">The file is too big and/or of the wrong type. Only .jpg files smaller than 70kB may be uploaded!</p>";


<form enctype="multipart/form-data" action="" method="POST">
  <input type="hidden" name="MAX_FILE_SIZE" value="71680">
  <p class="noindent">
  File name: <input name="filename" type="file">
  <input type="submit" value="Upload">
<p class="noindent">Maximum file size is 70kB. Only .jpg files may be uploaded.</p>

<h2>File Listing</h2>


while($file = readdir($dir)) {
    if($file != "." && $file != ".." && $file != "index.php") {
        $sortfiles[] = $file;


foreach ($sortfiles as $sortedfile) {
    echo"<li><a href=\"$sortedfile\" target=\"_blank\">$sortedfile</a></li>\n";

echo "</ul>\n";



Old 07-17-04, 04:17 PM
DVD Talk Ultimate Edition
Join Date: Apr 2000
Location: Austin, Texas XboxLIVE Gamertag: Golucky Timezone: Central (CST)
Posts: 4,899
Likes: 0
Received 0 Likes on 0 Posts
I use a sweet free upload script that I got from celerondude.com, and modified it. If you don't want to reinvent the wheel you might want to try this one out.

Check it out here. http://www.golucky.net/uploader

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.