chanfuterboy Posted August 7, 2009 Share Posted August 7, 2009 Hi, I was working on a uplaod script, after i upload a picture in a form in a separate page, the upload script keep in blank why? should i mist something? <?php // if something was posted, start the process... if(isset($_POST['upload'])) { // define the posted file into variables $name = $_FILES['picture']['name']; $tmp_name = $_FILES['picture']['tmp_name']; $type = $_FILES['picture']['type']; $size = $_FILES['picture']['size']; // get the width & height of the file (we don't need the other stuff) list($width, $height, $typeb, $attr) = getimagesize($tmp_name); // if width is over 600 px or height is over 500 px, kill it if($width>600 || $height>500) { echo $name . "'s dimensions exceed the 600x500 pixel limit."; echo ?> <a href="form.html">Click here</a> to try again. <? ; die(); } // if the mime type is anything other than what we specify below, kill it if(!( $type=='images/jpeg' || $type=='images/png' || $type=='images/gif' )) { echo $type . " is not an acceptable format."; echo ?> <a href="form.html">Click here</a> to try again. <? ; die(); } // if the file size is larger than 350 KB, kill it if($size>'350000') { echo $name . " is over 350KB. Please make it smaller."; echo ?> <a href="form.html">Click here</a> to try again. <? ; die(); } // if your server has magic quotes turned off, add slashes manually if(!get_magic_quotes_gpc()){ $name = addslashes($name); } // open up the file and extract the data/content from it $extract = fopen($tmp_name, 'r'); $content = fread($extract, $size); $content = addslashes($content); fclose($extract); // connect to the database include "connect.php"; // the query that will add this to the database $addfile = "INSERT INTO files (name, size, type, content ) ". "VALUES ('$name', '$size', '$type', '$content')"; mysql_query($addfile) or die(mysql_error()); // get the last inserted ID if we're going to display this image next $inserted_fid = mysql_insert_id(); mysql_close(); // display the image ?> <div align="center"> <strong><? echo $name; ?><br> </strong><img name="<? echo $name; ?>" src="getpicture.php?fid=<? echo $inserted_fid; ?>" alt="Unable to view image #<? echo $inserted_fid; ?>"> <br> <a href="form.html">upload more images</a> </div> <? // we still have to close the original IF statement. If there was nothing posted, kill the page. }else{die("No uploaded file present"); } ?> Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/ Share on other sites More sharing options...
alexdemers Posted August 7, 2009 Share Posted August 7, 2009 Like some people have here in their signature: <?php ini_set('display_errors', 1); error_reporting(E_ALL | E_STRICT); ?> Put that at the top of your file. You will know any errors. Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892847 Share on other sites More sharing options...
chanfuterboy Posted August 7, 2009 Author Share Posted August 7, 2009 hi, i try it that, but the page is not getting up Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892851 Share on other sites More sharing options...
br3nn4n Posted August 7, 2009 Share Posted August 7, 2009 Just thinking the exact same thing. Or check your PHP error log, it should tell you. If there's no errors, try to do a var_dump($_POST['upload']) and see what you get (if anything). Put this in the top of the script that processes the upload: error_reporting(E_ALL); And report back Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892853 Share on other sites More sharing options...
chanfuterboy Posted August 7, 2009 Author Share Posted August 7, 2009 hi, still nothing Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892854 Share on other sites More sharing options...
alexdemers Posted August 7, 2009 Share Posted August 7, 2009 It could be one of your die(). Follow the logic and try var_dump()ing different variables to see where your logic goes. Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892855 Share on other sites More sharing options...
ldougherty Posted August 7, 2009 Share Posted August 7, 2009 So how exactly is your script supposed to work, you state something about "uploading a picture in a form in a separate page". Does the upload itself actually work or no? If you can give us the URL where you are running this script it might be helpful so we can see the code in action. Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892857 Share on other sites More sharing options...
br3nn4n Posted August 7, 2009 Share Posted August 7, 2009 So how exactly is your script supposed to work, you state something about "uploading a picture in a form in a separate page". Does the upload itself actually work or no? If you can give us the URL where you are running this script it might be helpful so we can see the code in action. Pretty sure we're not allowed to self-promote around here, even if it's in order to help solve coding problems...not sure if I'm wrong about that rule.. Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892861 Share on other sites More sharing options...
chanfuterboy Posted August 7, 2009 Author Share Posted August 7, 2009 Yes i got the error it was those lines echo ?> <a href="form.html">Click here</a> to try again. <? Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892871 Share on other sites More sharing options...
chanfuterboy Posted August 7, 2009 Author Share Posted August 7, 2009 now i have another problem, when i upload a name let say winter.php in upload script it change the name in another name, put that the upload does not read it. what can be the problem? Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892880 Share on other sites More sharing options...
br3nn4n Posted August 7, 2009 Share Posted August 7, 2009 Can you rephrase that? Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892899 Share on other sites More sharing options...
chanfuterboy Posted August 7, 2009 Author Share Posted August 7, 2009 ok, i have form.html there I upload a picture winter.jpg. as it check the upload.php script, it result the image, with another name + extention. why is that happening? Link to comment https://forums.phpfreaks.com/topic/169214-upload-scrip-blank/#findComment-892900 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.