
November 18th, 2012, 08:44 AM
|
 |
Contributing User
|
|
Join Date: Jan 2006
Posts: 122

Time spent in forums: 1 Day 13 h 57 m 38 sec
Reputation Power: 8
|
|
|
Php script not uploading or posting any errors
Hi  everyone i am developing and testing site with xampp everything seams to be going fine until i starting having issues with this upload script. For some reason the $_POST is not being set when the submit button is being pressed. also no errors are being displayed. I put a few echo points to see how far along the script was getting and i guess it wasnt so far. im sure im over looking something small and it will be a palm to face moment but i have to get this work asap.. Thx
PHP CODE:
Code:
<?php include_once("scripts/global.php");
//session_start;
$displaymessage = 'Upload a new image';
if(isset($_POST['submit'])){
echo ("Post is set");
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/jpg"))
&& ($_FILES["file"]["size"] < 200000)
&& in_array($extension, $allowedExts))
{
echo ("File allowed");
if ($_FILES["file"]["error"] > 0)
{
echo "Error >> " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("user/".$session_id."/")){
if (file_exists("user/".$session_id."/" . $_FILES["file"]["name"]))
{
$displaymessage = ">> ".$_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"user/".$session_id."/" . $_FILES["file"]["name"]);
$displaymessage = ">> Your file has been uploaded:". $_FILES["file"]["name"];
}
}else{
mkdir("user/".$session_id."/");
move_uploaded_file($_FILES["file"]["tmp_name"],
"user/".$session_id."/" . $_FILES["file"]["name"]);
$displaymessage = ">> Your file has been uploaded:". $_FILES["file"]["name"];
}
}
}
else
{
$displaymessage = ">> Invalid file";
}
}
?>
Here is the form snipit
Code:
<span class='SoicalHeader_center'><?php print ("".$displaymessage.""); ?></span>
<form action="manage_my_photos.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image" id="image"/></br>
<input name="upload" type="submit" value="Upload" />
</form>
Last edited by IMaVBNoob : November 18th, 2012 at 09:01 AM.
|