"File Uploading" graphic

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
Da_Elf
Forum Commoner
Posts: 81
Joined: Mon Dec 29, 2008 12:31 pm

"File Uploading" graphic

Post by Da_Elf »

ive searched around for an answer to this but keep hitting walls. i want to be able to have an upload script that will show an animated "uploading" graphic when i click the submit button. unfortunately it shows it after the file is uploaded which is useless. i dont want to go as complex as a progress bar. just a simple graphic.
User avatar
awebtech
Forum Newbie
Posts: 21
Joined: Sun Nov 07, 2010 4:54 pm
Location: Russian Federation

Re: "File Uploading" graphic

Post by awebtech »

Hi, you definitely need some JavaScript magic to implement uploading animation.

For example, you can post file to a hidden iframe and in the same time start animation. As soon as file is uploaded, iframe will echo the JS-code, which will stop animation at the main page.
Da_Elf
Forum Commoner
Posts: 81
Joined: Mon Dec 29, 2008 12:31 pm

Re: "File Uploading" graphic

Post by Da_Elf »

so should i have an "onclick" event that will run as soon as i click the submit button? i saw other sites talking about AJAX which i dont know and i want to keep it as simple as possible
Da_Elf
Forum Commoner
Posts: 81
Joined: Mon Dec 29, 2008 12:31 pm

Re: "File Uploading" graphic

Post by Da_Elf »

for anyone who is interested this is what i used finally. hope its of help. thanks awebtech for steering my brain down the right road

Code: Select all

<?php
session_name("..........");
session_start() ;
$isadmin = $_SESSION [ "level" ];
if ($isadmin == 1){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image</title>
function imageUploading() {
document.getElementById("uploading").style.visibility = 'visible';
}
//-->
</script>
</head>

<body>
<form action="........." method="post" enctype="multipart/form-data" class="uniForm" name="image">
<input name="upim" size="25" type="file" />
<input class="button1" type="submit" name="upimage" value="Submit Image" onclick="imageUploading();"><br /><BR />
<span id="uploading" style="visibility:hidden">IMAGE UPLOADING<img src="../Images/loader.gif"/></span>
</form>
</body>
</html>
<?php } //closeing admin check
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: "File Uploading" graphic

Post by Darhazer »

You can use a flash uploader like uploadify to show real progress bar.
Or you can upload in an iframe and show progress with ajax, if you use PHP 5.2+ with APC
User avatar
awebtech
Forum Newbie
Posts: 21
Joined: Sun Nov 07, 2010 4:54 pm
Location: Russian Federation

Re: "File Uploading" graphic

Post by awebtech »

Da_Elf, thanks for posting your solution :) Other people will be able to solve the same problem.
Post Reply