User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,569 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,575 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 495 | Replies: 2
Reply
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Solution Uploading progress

  #1  
Oct 23rd, 2007
everything works fine... i upload any picture or file that i allowed
the things is, i want to add uploading progress

any ideas??

here is my code....

<?php
//--------------------------------------------------------------------------------
$path = "";
$web = "../uploads/";
$nopic = "nopic.jpg";
$ad = "add_item";
$no = "1";
$page = $ad.$no;
//--------------------------------------------------------------------------------
$isim = $_REQUEST['NewsID'];
$tip = $_FILES[img1][type];
$size = $_FILES[img1][size];
//--------------------------------------------------------------------------------
$Edit = $_COOKIE['Edit'.$no];
if($Edit != "")
{
$GetID = "select * from news where NewsID='" . $isim . "'";
$FindID=mysql_query($GetID);
while($WriteID = mysql_fetch_array($FindID))
{
	if($WriteID['Resim'.$no] != "")
	{
	setcookie('Edit'.$no,'');
	$dosya = $WriteID['Resim'.$no];
	}
	else
	{
	setcookie('Edit'.$no,'');
	$dosya = $nopic;
	}
}
}
//--------------------------------------------------------------------------------
elseif($size >= 150000)
{
	$dosya = $nopic;
	//Temizle
	$sil1 = $isim."_".$no.".jpg";
	$sil2 = $isim."_".$no.".png";
	$sil3 = $isim."_".$no.".gif";
	@unlink($path.$sil1);
	@unlink($path.$sil2);
	@unlink($path.$sil3);
	$uyari = "<small>Max 150Kb</small>";
}
//--------------------------------------------------------------------------------
elseif($tip == "image/jpeg" || $tip == "image/pjpeg")
{
	$dosya = $isim."_".$no.".jpg";
	//Temizle
	$sil1 = $isim."_".$no.".jpg";
	$sil2 = $isim."_".$no.".png";
	$sil3 = $isim."_".$no.".gif";
	@unlink($path.$sil1);
	@unlink($path.$sil2);
	@unlink($path.$sil3);
	$query = "update news set Resim". $no ." ='" . $dosya . "' where NewsID=". $isim ."";
	mysql_query($query) or die(mysql_error());
	@copy($_FILES[img1][tmp_name],$path.$dosya);

}
//--------------------------------------------------------------------------------
elseif($tip == "image/png" || $tip == "image/x-png")
{
	$dosya = $isim."_".$no.".png";
	//Temizle
	$sil1 = $isim."_".$no.".jpg";
	$sil2 = $isim."_".$no.".png";
	$sil3 = $isim."_".$no.".gif";
	@unlink($path.$sil1);
	@unlink($path.$sil2);
	@unlink($path.$sil3);
	$query = "update news set Resim". $no ." ='" . $dosya . "' where NewsID=". $isim ."";
	mysql_query($query) or die(mysql_error());
	@copy($_FILES[img1][tmp_name],$path.$dosya);
}
//--------------------------------------------------------------------------------
elseif($tip == "image/gif")
{
	$dosya = $isim."_".$no.".gif";
	$sil1 = $isim."_".$no.".jpg";
	$sil2 = $isim."_".$no.".png";
	$sil3 = $isim."_".$no.".gif";
	@unlink($path.$sil1);
	@unlink($path.$sil2);
	@unlink($path.$sil3);
	$query = "update news set Resim". $no ." ='" . $dosya . "' where NewsID=". $isim ."";
	mysql_query($query) or die(mysql_error());
	@copy($_FILES[img1][tmp_name],$path.$dosya);
}
//--------------------------------------------------------------------------------
elseif($tip == "" )
{
	$dosya = $nopic;
}
//--------------------------------------------------------------------------------
elseif($tip != "image/jpeg" || $tip != "image/pjpeg" || $tip != "image/png" || $tip != "image/x-png" || $tip != "image/gif" || $tip != "")
{
	$dosya = $nopic;
	$uyari = "<small>Invalid file type</small>";
}
//--------------------------------------------------------------------------------
?>
<?php
$Delete = $_GET['Delete'];
$FileName = $_GET['FileName'];
if($Delete == "OK")
{
	$query = "update news set Resim". $no ." ='' where NewsID=". $isim ."";
	mysql_query($query) or die(mysql_error());
	@unlink($path.$FileName);
	$dosya = $nopic;
}
?>
<html>
<script language=JavaScript src='../js/controls.js'></script>
<script language="javascript">
// on loading show this picture
document.write('<div id="loading"><table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="center" height="100%"><br><img src="../images/loading.gif" alt="" align="middle"><br>Lütfen bekleyin...</td></tr></table></div>');

window.onload=function()
{
	document.getElementById("loading").style.display="none";
}
</script>
<body topmargin="0" leftmargin="0">
<form  method="post" action="<?php print $page ?>.php" enctype="multipart/form-data">
<table width="90" border="0" cellspacing="0" cellpadding="0">
<tr>
	<td align="center">
	<img name="img1" src="<?php if($dosya == $nopic) { print $dosya; } else { print $web.$dosya; } ?>" width="85" height="85">
	<?php if($dosya != $nopic) { $_POST[$dosya]; print "<br><a onclick='return resim_sil()' href=$page.php?Delete=OK&FileName=$dosya>Resmi Sil</a>&nbsp;"; } ?>
	<?php if($dosya == $nopic) { print $uyari;} ?>&nbsp;<br>
	</td>
</tr>
<tr>
<td>
<input type="file" name="img1"  accept="image/gif,image/jpeg,image/png" onChange="LimitAttach(this.form, this.form.img1.value)" size="1" style="width:80; border:none;">
</td>
</tr>
</table>
</form>
</body>
</html>
Do a favour, leave me alone
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: Uploading progress

  #2  
Oct 23rd, 2007
I think AJAX can solve your problem...
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Uploading progress

  #3  
Oct 23rd, 2007
Originally Posted by ryan_vietnow View Post
I think AJAX can solve your problem...


i dont need ajax... there are many examples made with php, but i dont like to copy and paste into my code...
Do a favour, leave me alone
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC