add page to allow file upload ??

expatCanuck

New Member
Greetings -

I'd like to be able to add a page to my site to let family members upload their photos of a recent joint trip.

No idea where to start.

Any pointers towards good examples, sample code, and teaching sites (e.g. - w3schools.com) would be welcome.

If it matters, Linux is the server OS on which my site resides, and my family will likely upload their photos from Apple Mac computers. But I don't have a Mac. So if a client 'OS-neutral' approach is possible, so much the better. I can likely get Linux up & running if it'd help (or be necessary) in testing (I seem to recall that the latest Apple OS is linux/unix-based).

I have written some vb database code, maybe a dozen lines of javascript, and some C back in college, so I do have a technical background (I'm a Business Systems Analyst by day). But I have minimal web development experience, so less is likely to be more, & simpler is better.

One thing that would certainly be welcome, tho', is password protection of the upload functionality.

Any & all help welcome.

Thanks kindly.

- Richard

oldWithoutMoney.com
 
Last edited:

rbxslvr

New Member
Greetings -

I'd like to be able to add a page to my site to let family members upload their photos of a recent joint trip.

No idea where to start.

Any pointers towards good examples, sample code, and teaching sites (e.g. - w3schools.com) would be welcome.

If it matters, Linux is the server OS on which my site resides, and my family will likely upload their photos from Apple Mac computers. But I don't have a Mac. So if a client 'OS-neutral' approach is possible, so much the better. I can likely get Linux up & running if it'd help (or be necessary) in testing (I seem to recall that the latest Apple OS is linux/unix-based).

I have written some vb database code, maybe a dozen lines of javascript, and some C back in college, so I do have a technical background (I'm a Business Systems Analyst by day). But I have minimal web development experience, so less is likely to be more, & simpler is better.

One thing that would certainly be welcome, tho', is password protection of the upload functionality.

Any & all help welcome.

Thanks kindly.

- Richard

oldWithoutMoney.com
I'd say that you should use PHP. If you don't need specifically family members to have specific permissions, you could easily hard-code in a password and just give that password to family members. Then, all you would have to take care of would be the image uploading itself, which there are many different tutorials/code examples on.

I'll find something you could use here in a few minutes, I'm working on my site right now.

With PHP though, you can insert a conditional if-then statement to verify the user.... if the user typed the right password, allow the file to be uploaded, or else echo("Access Denied... you aren't my family!")
 

rbxslvr

New Member
Alright, I'm back with something that may help... First, create an "Upload" page on your site, and a directory to upload the images to.

Insert this code into that page:
HTML:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
Upload Password: <input type="password" name="password" /><br/>
<input type="submit" value="Upload File" />
</form>


Now, create a new file called "uploader.php", in the same directory as you created the image directory in. Insert the following and save it:

PHP:
<?php
$password = $_POST['password'];
if($password == "PASSWORD") {

}
else {
die("Wrong password.  Access Denied.");
}
$target_path = "images/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

Now, in that PHP file, you can edit "images/" to match the directory that you created. You can also switch any of the text strings, such as "Wrong password...."... obviously, the password in this one is "PASSWORD", as indicated by the conditional statement.

Now, this won't show your pictures, but it will allow them to be uploaded to a directory in your site, and you can insert them into pages later, or write another php script to scan the directory for files and display the images in thumbnails, like a photoalbum. If this is what you are going for, let me know, and I'll try to get back to you with some more code.

I don't know if I was clear about where to put the files, so I'll just do this:

Yoursite/
----images/
----------------uploadedimage1.jpg
----------------uploadedimage2.jpg
----------------uploadedimage3.jpg
----FileUpload.htm
----Uploader.php


Make sure your web host supports PHP. I know that most major ones do... such as GoDaddy.
 
Last edited:
Top