Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

Welcome to Webmaster Forums 101!

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th May 2005, 10:31 AM   #1

Username: dvgulik
Rank: WF101 Newbie
Join Date: May 2005
Posts: 13
Points: 30.28
Default Uploading Files Using PHP question

Hi there,

I'm a total PHP novice, but I just went though and completed Ben Sinclair's tutorial on how to upload files using PHP:

http://www.devpapers.com/article/41

I found it very easy to follow and got it working relatively easily. However, being the novice that I am, I had a caople questions regarding some modifications:

1) Can the PHP be modified to allow for an email notification every time someone uploads something to your server?

2) I would like to have some html displayed instead of the plain-text "Your file has been uploaded" that appears upon successfully uploading a file.

3) a "Close Window" button would be great at the end, as well.

I would totally appreciate it if someone could help me out with these things... Thanks very much!

David
dvgulik is offline   Reply With Quote
Old 11th May 2005, 10:44 AM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Answers to your questions:

1) To get emailed when an image is uploaded, above print "Your file has been uploaded successfully! Yay!"; add this code:

PHP Code:
$your_email ""// Your email address
$your_subject ""// The subject of the email
$message ""// The message in the body of the email
@mail($your_email$your_subject$message"From: \"$your_email\"<$your_email>\r\nReply-To:     $email\r\nX-Sender:$your_email using $your_email\r\nReturn-Path: $your_email"); 

2) To modify the thank you message just edit between print " and " of the code below. If you have any " in the html you need to add a \ in front of it. E.g: (<a href=\"link.php\">Text</a>).

print "Your file has been uploaded successfully! Yay!";

3) To close the window add this code to the tahnk you message: <a href="javascript:window.close();">Close Window</a>

Hope that helps.
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 11th May 2005, 11:27 AM   #3

Username: dvgulik
Rank: WF101 Newbie
Join Date: May 2005
Posts: 13
Points: 30.28
Default

Mr. Tech,

Brilliant.

Everything worked flawlessly - Thank you!

David
dvgulik is offline   Reply With Quote
Old 11th May 2005, 11:39 AM   #4
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

I love it when that happens

No problem, glad to help.
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 11th May 2005, 05:21 PM   #5

Username: dvgulik
Rank: WF101 Newbie
Join Date: May 2005
Posts: 13
Points: 30.28
Default

Mr. Tech,

Upon playing around with this file-uploader, another question occured to me:

Would it be difficult to code in a small gif animation to play during the time a large file is being uploaded? I was just thinking that if someone was uploading a several-megabyte file there would be a bit of a delay, so a little "loading animation" of some kind would be appropriate.

Any suggestions on how to do that?

Thanks again!
David
dvgulik is offline   Reply With Quote
Old 12th May 2005, 09:36 AM   #6
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

You'll have to find someone to create you one or find one on another website.... It would be an image... There may be a method to show the exact loading time but I'm not sure what... Maybe some javascript... You might be able to find out the file size and then compare it with the uploading speed to give an accurate time...

Here's a couple of images I found on my computer... Maybe they will suit your script..
Attached Thumbnails
Click image for larger version

Name:	loading.gif
Views:	31
Size:	2.1 KB
ID:	8  Click image for larger version

Name:	progress_bar.gif
Views:	33
Size:	787 Bytes
ID:	9  
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 12th May 2005, 10:26 AM   #7

Username: dvgulik
Rank: WF101 Newbie
Join Date: May 2005
Posts: 13
Points: 30.28
Default

Oops - sorry for not being more clear (upon re-reading my question, it's a bit muddled..)

Actually, I know how to make animated gifs and all that, I was just wondering if there was a way to include one in the PHP code so that it automatically plays during an upload. (a short, loading loop)

If it involves 're-inventing the wheel' - so to speak - with the PHP code then don't worry about it - I just thought it would be a nice feature.

David
dvgulik is offline   Reply With Quote
Old 12th May 2005, 11:12 AM   #8
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

So are you wanting to display an image to show progress or do you want the "exact" progress to be shown?
Are you wanting the upload file to "play" once uploaded?

You'll need to be a little mroe clear I'm afraid...
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 12th May 2005, 11:34 AM   #9

Username: dvgulik
Rank: WF101 Newbie
Join Date: May 2005
Posts: 13
Points: 30.28
Default

Sorry - sometimes I type faster than I think!

This was my concern:
When you browse for a file and then click the "upload" button, if you happen to be uploading a large file, you may end up waiting up to a minute with nothing happening.

Once the file uploads, some html is displayed saying "Successfully Uploaded"... but until the file is finished uploading, there's no way of knowing if anythings actually happening.

I was thinking it would be nice to have a small gif animation playing during the uploading wait. It doesn't have to show the exact progress or anything, just a simple loop for the sole purpose of letting the user know that the file is indeed being uploaded.

So basically the animated gif would play between the time the "Upload" button is clicked until the file is finished uploading.

Once the file finished uploading, the "Successfully Uploaded" html would replace the animated gif, and the user can close the window.

I was just wondering how to incorporate the little animated gif loop into the PHP...

David
dvgulik is offline   Reply With Quote
Old 12th May 2005, 12:17 PM   #10
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Ahh, I see now Yep, that can be a pain... Here's a sample form...

Code:
<form action="index.php?uploaded=true" method="post" ENCTYPE="multipart/form-data"> File:<br><input type="file" name="userfile" size="30"><br> <input type="submit" value="Upload!" onClick="document.getElementById('waiting').style.display = '';document.getElementById('body').style.cursor = 'wait'"><br><br> <div id="waiting" style="text-align: left; display: none; padding: 5px;"> <font color="red">Please wait while the file uploads...</font> </div> </form>

All you need to do is ad the bolded code to your code and add the image code between <div id="admin" style="text-align: left; display: none; padding: 5px;"> and </div>
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 08:41 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore