•
•
•
•
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
![]() |
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....
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> "; } ?>
<?php if($dosya == $nopic) { print $uyari;} ?> <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
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
I think AJAX can solve your problem...
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Google Backlink Update in Progress 10/16 (Search Engine Optimization)
- JProgressBar while file copying (Java)
- Problems with internet uploading levels (Networking Hardware Configuration)
- saving progress (C++)
- Uploading Folders to Web in OSX.3.7 (OS X)
- Work in progress, Opinions, HWGuru.com (Website Reviews)
- uploading image in database (PHP)
- computer times out when uploading filles (Web Browsers)
- Uploading files using HTTP/X and CGI (Shell Scripting)
- uploading .txt file via phpmyadmin to Mysql (MySQL)
Other Threads in the PHP Forum
- Previous Thread: Make my own IM program and MySpace Clone.
- Next Thread: To retrieve the array value in javascript


Linear Mode