cancel
Showing results for 
Search instead for 
Did you mean: 

Allow visitors to upload files

SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

Allow visitors to upload files

I want to be able to allow visitors to my FP site to upload their images via the file upload control but the properties of the destination folder are disabled so therefore i cannot allow the destination folder to receive files.
Any ideas?
3 REPLIES
SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

Re: Allow visitors to upload files

The error message i get when i try to upload a file is as follows:
Cannot run the FrontPage Server Extensions on this page: "http://fp.mywebspace.plus.com/submitimage.htm"
I am trying to provide an image upload feature to my site using the FP file upload componenent
Is this an unavailable feature on the FP server?
SoulBriski
Grafter
Posts: 179
Registered: ‎15-06-2007

Re: Allow visitors to upload files

I think i've given up on this now, no one was answering anyway.
I think a better option might be to put my site on the cgi server and achieve the file upload via php scripts where i can also do a lot more dynamically.
Trouble is, i don't know much about php, all the examples i've tried for uploading files don't work, most likely because i am not aware of all the different bits i need
Will someone please post a working example of some php code that will allow a website visitor to upload an image.
This is my upload.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<?php
   
$uploaddir = 'ftp://ccgi.username.plus.com/images/';
$uploadfile = $uploaddir . basename($_FILES['imagefile']['name']);
if (is_uploaded_file($_FILES['imagefile']['tmp_name'])) {
  echo "File ". $_FILES['imagefile']['name'] ." uploaded successfully.\n";
  echo "Displaying contents\n";
  readfile($_FILES['imagefile']['tmp_name']);
} else {
  echo "Possible file upload attack: ";
  echo "filename '". $_FILES['imagefile']['tmp_name'] . "'.";
}
?>
<p>File name to be uploaded = <?php echo $_FILES['imagefile']['name']; ?></p>
<p>Upload location = <?php echo $uploadfile; ?></p>

</body>
</html>

The upload.php above is called from the following submitimage.htm
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<form method="POST" action="upload.php" enctype="multipart/form-data">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
    <!-- Name of input element determines name in $_FILES array -->
<input type=file name="imagefile" value="Image file submitted">
<p><input type="text" name="T1" size="20"></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>

Although it appears to work in that the message displayed at the end gives the impression the file was uploaded sucesfully, the image does not appear on the server where i expected it to be.
Barghest
Newbie
Posts: 1
Registered: ‎15-09-2007

Re: Allow visitors to upload files

What you have should only need one change to get it working. In the upload.php you need to change the $uploaddir to the path to your space, which can be obtained by running 'pwd' whilst connected with Putty (or your preferred client) For reference, I've included a copy of the appropriate code in mine.
$uploaddir = '/var/www/html/choc-cha/images/';
$uploadname = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
  echo "File uploaded.\n";
} else {
  echo "Possible file upload attack!\n";
}

Edit: Though after reading through some other posts it would appear that you've found an alternate way of doing what you were after, so I'll just leave this here for anyone else who has similar issues. Smiley