HTML posting to soon?

Discussion in 'PHP' started by Sleeping Troll, Aug 25, 2008.

  1. #1
    I am uploading an image to the server in an iframe, however the iframe does not reflect the new upload unless I refresh page. I suspect what is happening is that the html is posting before upload is complete. Here is the source for the iframe. Is my assumption correct, if so how do I wait on download to complete before posting html?

    <?php
    $conn = mysql_connect("xxx","xxx","xxx"); 
    mysql_select_db("xxx",$conn);
    $SQL="Select * From Projects where ClientID = $ClientID and Status = 'Current'";
    $ClientID = $_COOKIE["Brag_Flag_user"];
    $SQL="Select * From Projects where ClientID = $ClientID and Status = 'Current'";
    $result = mysql_query($SQL);
    $row = mysql_fetch_array($result);
    $ProjectID = $row["ProjectID"];
    $file = "Images/Client_Photos/".$ProjectID.".jpg";
    $_FILES['UploadFile']['tmp_name']; 
    move_uploaded_file($_FILES['UploadFile']['tmp_name'],$file);
    $percent = 0.25;
    header('Content-type: image/jpeg');
    list($width, $height) = getimagesize($file);
    $newwidth = $width * $percent;
    $newheight = $height * $percent;
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $source = imagecreatefromjpeg($file);
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    $file = "Images/Preview_Photos/".$ProjectID.".jpg";
    @imagejpeg($thumb, $file);
    echo "<html>";
    echo "<head>";
    echo "<style type='text/css'>";
    echo "#LayerPhoto {";
    echo "	position:absolute;";
    echo "	z-index:2;";
    echo "	top: 0px;";
    echo "	left: 0px;";
    echo "}";
    echo "</style>";
    echo "</head>";
    echo "<body>";
    echo "	<div align='center'>";
    echo "		<div id = 'LayerPhoto'><img src = '".$file."' id='Photo'></div>";
    echo "		</div>";
    echo "</body>";
    echo "</html>";
    ?>
    Code (markup):
     
    Sleeping Troll, Aug 25, 2008 IP
  2. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why not run an IF statement to check if it's been uploaded, and if it has, then you will output the HTML? :-/
     
    Wrighty, Aug 25, 2008 IP
  3. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If (what?)
     
    Sleeping Troll, Aug 25, 2008 IP