On 22 January 2009 c. 16:26:08 pcnico...@freesurf.fr wrote: > Hi > > I need a very simple web page to upload files on my Apache web server. > I found some cgi script like this one > http://www.raditha.com/megaupload/ but I always face "internal server > error" message.
Did you look at the logs in /var/www/logs? > Did anyone done some like that ? See the code at the end of letter. I'm using such page myself, secured by HTTP authorization, so there are not so many security and reliability checks in the code. You need to install php5-core package, of course. -- WBR, Pereresus ne Vlezaet Buggy <?php // $Id$ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>File download page</title> </head> <body> <h1>File uploading</h1> <?php if (count($_FILES) > 0 && $_FILES['userfile']['tmp_name'] != '' && is_uploaded_file($_FILES['userfile']['tmp_name'])) { $basename = basename($_FILES['userfile']['name']); $t = time(); $newname = '/upl/files/'.$t.'_'.$basename; if (rename($_FILES['userfile']['tmp_name'], $newname)) { chmod($newname, 0644); echo '<p>File <strong>'.htmlspecialchars($basename). '</strong> uploaded successfully!</p>'; $linkpath = '/dnl/auto/'.$t.'_'.$basename; if (link($newname, '/htdocs'.$linkpath)) { $url = 'http://'.$_SERVER['SERVER_NAME'].$linkpath; echo '<p>File can be downloaded via link: <a target="_blank" href="'. htmlspecialchars($url).'">'.htmlspecialchars($url).'</a></p>'; } else { $linkFailed = 1; echo '<p>For downloading the file please ask the administrator.</p>'; } } else { echo '<p>Sorry, server error occured. Please try again later.</p>'; } require 'Net/SMTP.php'; $host = 'mail.my.domain'; $subj = "Subject: New file uploaded\r\n"; $body = "New file\r\n$basename\r\n". "can be found in /upl/files/ directory.\r\n"; if (isset($renameFailed)) $body .= "ERROR: failed to move uploaded file\r\n"; if (isset($linkFailed)) $body .= "WARNING: failed to create hard link in /htdocs/dnl/auto\r\n"; if (($smtp = new Net_SMTP($host))) { if (!PEAR::isError($smtp->connect())) { if (!PEAR::isError($smtp->mailFrom('w...@my.domain'))) { if (!PEAR::isError($smtp->rcptTo('ad...@my.domain'))) { $smtp->data($subj . "\r\n" . $body); } } $smtp->disconnect(); } } } ?> <p> <form method="post" enctype="multipart/form-data"> <label for="userfile">File:</label> <input name="userfile" type="file" id="userfile"> <input type="submit" value="Upload" /> </form> </p> </body> </html> -- Best wishes, Vadim Zhukov