...

View Full Version : Upload script, sometime work other's won't



Peuplarchie
12-24-2007, 02:35 AM
Good day to you all,
I have a problem with a image upload script.
When a user upload 3 image back to back, it give a error .




<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<title>Test</title>
<STYLE TYPE="text/css">
<!--

a:hover{text-decoration: underline ;}
a:hover{font-weight: bold;}

.blue00 {
font-size: 12px;
font-family: georgia, Arial, Helvetica, sans-serif;
text-decoration: none;
color: #003366;}

.white00 {
font-size: 12px;
font-family: georgia, Arial, Helvetica, sans-serif;
text-decoration: none;
color: #ffffff;}

//-->
</STYLE>









<script type="text/javascript">

/***********************************************
* Ajax Includes script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//To include a page, invoke ajaxinclude("afile.htm") in the BODY of page
//Included file MUST be from the same domain as the page displaying it.

var rootdomain="http://"+window.location.hostname

function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url, false) //get page synchronously
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}

</script>






</head>
<body bgcolor="#000000" align="center" text="white">





<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td width="1000" align="center" bgcolor="#000000"><table border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td width="1000" bgcolor="#000000" valign="top"><table border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td width="1000" bgcolor="#000000" valign="top" align="center">
<script type="text/javascript">
ajaxinclude("http://test.info/0-1/entete.php")
</script>
<br>
<script type="text/javascript">
ajaxinclude("http://test.info/0-1/menu.html")
</script>
</td>


<tr><td width="1000" bgcolor="#000000" valign="top" align="center"><br><b class="white00">Add Photos</b></td></tr>
<tr><td width="1000" bgcolor="#000000" valign="top"><br></td></tr>

<tr><td width="630" bgcolor="#000000" valign="top">








<?php
//Here is the processing start


$path1= "../../Art/Pictures/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "../../Art/Pictures/".$HTTP_POST_FILES['ufile']['name'][1];

$dname = $_POST["bob"];
$cname = $_POST["cat"];
$fname = $HTTP_POST_FILES['ufile']['name'];
$tfname = $HTTP_POST_FILES['ufile']['tmp_name'];
//Here is what give me proglem
foreach ($fname as $f) {
foreach ($dname as $d) {
foreach ($cname as $c) {
$sfolder = substr($d, 29);
$categ = substr($c, 33);
$sname = $f;





//copy file to where you want to store file
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], "../../Art/Pictures/Pic-S".$sfolder."/".$HTTP_POST_FILES['ufile']['name'][0]);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], "../../Art/Pictures/Pic-B".$sfolder."/".$HTTP_POST_FILES['ufile']['name'][1]);
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], "../../Art/Pictures/Cat/Pic-S".$categ."/".$HTTP_POST_FILES['ufile']['name'][0]);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], "../../Art/Pictures/Cat/Pic-B".$categ."/".$HTTP_POST_FILES['ufile']['name'][1]);




}
}
}




echo "<br/><b> Pour en uploader encore <a href=\"ajout_images.php\" class=\"white00\">Cliquer ici.</a></b><br/><br/>";
echo "Uploaded thumbnail.\n\r<BR/>";
echo "Uploaded original picture.\n\r<BR/>";

$name0 = $HTTP_POST_FILES['ufile']['name'][0]; // striping the extension
preg_match('/^(.*?)\..*$/',$name0,$matches);
$fh = fopen($matches[1] . '.txt', 'w') or die("Can't open file!");
$commentaires1 = $_POST['commentaires0'];
$commentaires2 = wordwrap($commentaires1, 35, "<br />\n", true);
fwrite($fh, $commentaires2);
fclose($fh);

$text = $_POST['prix0'];
$correctingtext = htmlentities($text, ENT_QUOTES);
$newstr = stripslashes($correctingtext);
$goodtext = html_entity_decode($newstr);
$fh0 = fopen($matches[1] . '_prix.txt', 'w') or die("Can't open file!");
fwrite($fh0, $goodtext);
fclose($fh0);


$text1 = $_POST['vente0'];
$nameitem = $_POST['nameitem'];
$pattern = '/AAAAAAAAAA/';
$newstr2 = preg_replace($pattern, $nameitem, $text1);
$correctingtext1 = htmlentities($newstr2, ENT_QUOTES);
$newstr1 = stripslashes($correctingtext1);
$goodtext1 = html_entity_decode($newstr1);
$fh1 = fopen($matches[1] . '_vente.txt', 'w') or die("Can't open file!");
fwrite($fh1, $goodtext1);
fclose($fh1);

$source = $matches[1] . ".txt";
$destination = "../../Art/Pictures/Commentaires/" . $matches[1] . ".txt";


$source1 = $matches[1] . "_vente.txt";
$destination1 = "../../Art/Pictures/Vente/" . $matches[1] . ".txt";


if(copy($source, $destination)) {
echo "Author comment saved successfully.\n\r<BR/>";
echo "Images copied successfully.\n\r<BR/>";

copy("comments.txt", "../../Art/Pictures/Pics/Comments/" . $matches[1] . ".txt");
copy("gestion_commentaires_plus.inc", "../../Art/Pictures/Comments/" . $matches[1] . ".inc");
echo "Comments page created successfully.\n\r<BR/>";

copy($source1, $destination1);
echo "Price saved successfully and ready for sale.\n\r<BR/>";




copy("item_1.rating", "../../Art/Pictures/Pics/Rating/" . $matches[1] . ".rating");
echo "Rating page created successfully.\n\r<BR/>";
$do = unlink("$source");
$myFile = "ajout_images_log.txt";
if($do=="1"){




$date=date ("d/m/y G:i:s A T");

$stringData = "\n<br>\n\n\r";
$stringData .= "\n<br>\n\n\r";
$stringData .= "\n<table border=0 align=center cellspacing=0 cellpading=0 width=\"1000\">\n";
$stringData .= "\n<tr><td bgcolor=\"#cccc99\" align=\"right\" class=\"white00\" width=\"1000\">\n";
$stringData .= "<b>".$date."</b>\n";
$stringData .= "</td></tr>\n";
$stringData .= "\n<tr><td bgcolor=\"#000000\" align=\"left\" class=\"white00\" width=\"1000\">\n";
$stringData .= "\n\r<b class=\"white00\">Name Thumbnail :</b>".$HTTP_POST_FILES['ufile']['name'][0]."<br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Name Original :</b>".$HTTP_POST_FILES['ufile']['name'][1]."<br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Taille Thumbnail :</b>".$HTTP_POST_FILES['ufile']['size'][0]." (bytes) <br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Taille Original :</b>".$HTTP_POST_FILES['ufile']['size'][1]." (bytes) <br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Type Thumbnail :</b>".$HTTP_POST_FILES['ufile']['type'][0]."<br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Type Original :</b>".$HTTP_POST_FILES['ufile']['type'][1]."<br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Commentaire :</b>" . $commentaires2."<br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Prix :</b>" . $_POST['prix0']."<br>\n\n\r";
$stringData .= "\n\r<b class=\"white00\">Paypal :</b>" . $_POST['vente0']."<br>\n\n\r";
$stringData .= "\n\rAuthor comment saved successfully.<br>\n\r\n\r";
$stringData .= "\n\rImages copied successfully.\n\r<br>";
$stringData .= "\n\rPrice saved successfully and ready for sale.<br>\n\r";
$stringData .= "\n\rComments page created successfully.<br>\n\r";
$stringData .= "</td></tr></table>\n";
$stringData .= "\n\r<br>\n\r\n\r";
$lines=file($myFile); //load the lines to an array
$insert_line = 1; //the line to insert at...could be a post variable
$insert_text = $stringData ; //this could be a post variable, but at any case make sure to append the var with the new line, otherwise it will run together
$temp=""; //start a temp variable to work with
$count=1; //initialize a counter
foreach($lines as $line){
$temp .= ($count != $insert_line) ? $line : $insert_text . $line;
$count++;
}

$fh000 = fopen($myFile, 'w') or die("can't open file");
fwrite($fh000, $temp);
fclose($fh000);







echo "<img src=\"../../Art/Pictures/Pics/Pic-S".$sfolder."/".$HTTP_POST_FILES['ufile']['name'][0]."\" width=\"150\" /><BR/>";
echo "<b>Name Thumbnail :</b>".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
echo "<b>Name Original :</b>".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>";
echo "<b>Taille Thumbnail :</b>".$HTTP_POST_FILES['ufile']['size'][0]." (bytes) <BR/>";
echo "<b>Taille Original :</b>".$HTTP_POST_FILES['ufile']['size'][1]." (bytes) <BR/>";
echo "<b>Type Thumbnail :</b>".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
echo "<b>Type Original :</b>".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>";
echo "<b>Commentaire :</b>" . $commentaires2."<BR/>";
echo "<img src=\"../../Art/Pictures/Pics/Pic-B".$sfolder."/".$HTTP_POST_FILES['ufile']['name'][1]."\" width=\"150\" />";
echo "<BR/><BR/>";

} else {


echo "There was an error.";
}
} else {
echo "The specified file could not be copied. Please try again.", "\n";
}






echo "<br/><br/><b> Pour en uploader encore <a href=\"ajout_images.php\" class=\"white00\">Cliquer ici</a></b><br/>";

?>
</table>


<tr><td width="1000" bgcolor="#000000" valign="top"><br></td></tr>
<tr><td width="1000" bgcolor="#000000" valign="top"><br></td></tr>


</table>
</table>
</table>
</table>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td bgcolor="#000000" valign="top"><table border="0" cellpadding="0" cellspacing="0" align="center">
<script type="text/javascript">
ajaxinclude("http://test.info/0-1/legal.php")
</script>
</td></tr>
</table>





</body>
</html>





I can't figure why cause sometime it work and sometime don't.
Can somebody help ?

mlseim
12-24-2007, 03:59 AM
Without testing or looking too hard, I'm sort of guessing you are having
a time-out problem with your webhost. They might limit the amount of
time your script runs, or the amount of bytes transferred. Find out if
you can see your PHP error logs on your server (or webhost). Find out
what the limits are.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum