image submission script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arkangel
Forum Newbie
Posts: 4
Joined: Sat Jan 17, 2004 1:08 am
Location: mission bc
Contact:

image submission script

Post by arkangel »

Hello, my name is phil. I am looking for an image submission script that would allow users to submit a photo to a folder on a server, only allow file sizes below two Mb and send two emails one to the webmaster to provide details of photo and one to the submitter.
I know that I would make a form and ask for all details then send emails to both parties based on that data. the rest of it is a complete mystery to me.
I have absoloutley no experience with php. Is this project two much too bite off for a beginner or is this a reasonable start?
Could anyone recommend a script similar or alike to this that I could look at?
please?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

It maybe a bit hard for a newbie, but you can still give it a shot. Just split it down into nice small tasks and then code each of this individualy.

1) Show form
2) Check that all required fields in the form were filled in.
3) Begin to check the file the use has uploaded - check the file type, width, height, size etc - use several if statments and display errors if any value is too high, or not too your liking.
4) Move the checked file from the tempory upload folder to where you want to store it.
5) Use the details from the rest of the form to send the emails that you wish to send.

Its quite hard to understand how uploads work to begin with so have a few pratices and see what happens and try to learn how it works. If you want a tutorial to follow then just search google and you will find several.
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Here are some good references for uploading:
http://www.php.net/manual/en/features.file-upload.php <-- official PHP documentation, read this thoroughly
http://codewalkers.com/tutorials/48/1.html
http://php.resourceindex.com/Documentat ... Uploading/

Good luck with your coding.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

heres a script similar to what you want,

Code: Select all

<?php
if(isset($_POST['submit']))
{
$upload_dir = "images/";//where files are uploaded to
$stripspaces = eregi_replace("_"," ",$_FILES["userfile"]["tmp_name"]);//replaces a space with a underscore
$ext = substr(strrchr($_FILES['userfile']['name'], '.'), 1);//gets file extension
$ext_array = array("jpg", "jpeg", "jpe", "tiff", "dib", "rle", "png", "tif", "bmp", "gif");//declares allowed file types

if (in_array($ext, $ext_array)) {  //checks file extention against allowed extentions
       copy($_FILES["userfile"]["tmp_name"], $upload_dir . $_FILES["userfile"]["name"]);

      echo "<p>Image uploaded successfully.</p>";

}
else
{
    echo "<p>Please upload image files only!</p>";
}
}
else
{
<html>
<head>
<title>File uploader</title>
<body>

<form enctype="multipart/form-data" action="uploader.php" method="post">

Choose file upload: <input name="userfile" type="file" /><br />

<input type="submit" value="Upload file" />

</form>
</body>
<html>
}

?>
you will have to modifiy it so it will also do the aditional tasks that you have requested........
may the force be with you!@#$%^&*
arkangel
Forum Newbie
Posts: 4
Joined: Sat Jan 17, 2004 1:08 am
Location: mission bc
Contact:

Thank you

Post by arkangel »

Thanks for all the help.
I looked at the jobs that I need to code and then put together. I am on the right track but I don't think I was very accurate. I am going to do this though, we'll see what happens.
Here is a very newbie question, how do I test php scripts on my computer. I am running win98.
I better post that question in a new topic though. Thanks again guys.
Phil
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

TO TEST A PHP script you will need to set up a webserver with php , i would suggest apache 1.37 but thats my preference
Post Reply