Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

HELP Po about Php

Status
Not open for further replies.

ScreamAimsFire

Proficient
Advanced Member
Messages
228
Reaction score
13
Points
38
Bakit po ganun wala po pumapasok na file sa directory ko pero nakukuha po nya yung name ng image na innupload ko :(

eto po code ko sa insert.php

Code:
<?php

	include("connection.php");

	if ($conn->connect_error) {

		die("Connection Failed" . $conn->connect_error);
	}

	$namelist = $_POST['username'];
	$section = $_POST['section'];
	$image = $_FILES['image']['name'];

	$sql = "INSERT INTO employee (name_list, section, image)
			 VALUES ('$namelist', '$section', '$image')";

    $msg = "";

	// if upload btn is pressed
	if (isset($_GET['submit'])) {
		
	//the path to store the uploaded image	
		$target = "images/".basename($_FILES['image']['name']);
	
    //now lets move the uploaded image into the folder images
		
		if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {

			$msg = "Image uploaded successfully";

		} else {

			$msg = "There was a problem uploading image";
		}
	}	


	if ($conn->query($sql) === TRUE) {

		header("Location:index.php");

	}

	else

	{

		echo "Error: " . $sql . "<br>" . $conn->error;
	}

$conn->close();

?>

gusto ko lang naman po ma view at pumasok yung name ng img sa db pero nakukuha naman na po yung name ng img ayaw lang po talaga pumasok sa directory yung image file :(

eto naman po nagiging out put ko, and nag didislpay lang po yung name ng img Koala.jpg
View attachment 321531

Sana po may makatulong Samalat :pray:
 

Attachments

  • img.png
    img.png
    9.9 KB · Views: 11
Last edited:
Bakit po ganun wala po pumapasok na file sa directory ko pero nakukuha po nya yung name ng image na innupload ko :(

eto po code ko sa insert.php

Code:
<?php

	include("connection.php");

	if ($conn->connect_error) {

		die("Connection Failed" . $conn->connect_error);
	}

	$namelist = $_POST['username'];
	$section = $_POST['section'];
	$image = $_FILES['image']['name'];

	$sql = "INSERT INTO employee (name_list, section, image)
			 VALUES ('$namelist', '$section', '$image')";

    $msg = "";

	// if upload btn is pressed
	if (isset($_GET['submit'])) {
		
	//the path to store the uploaded image	
		$target = "images/".basename($_FILES['image']['name']);
	
    //now lets move the uploaded image into the folder images
		
		if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {

			$msg = "Image uploaded successfully";

		} else {

			$msg = "There was a problem uploading image";
		}
	}	


	if ($conn->query($sql) === TRUE) {

		header("Location:index.php");

	}

	else

	{

		echo "Error: " . $sql . "<br>" . $conn->error;
	}

$conn->close();

?>

gusto ko lang naman po ma view at pumasok yung name ng img sa db pero nakukuha naman na po yung name ng img ayaw lang po talaga pumasok sa directory yung image file :(

eto naman po nagiging out put ko, and nag didislpay lang po yung name ng img Koala.jpg
View attachment 1215842

Sana po may makatulong Samalat :pray:

ok naman TS ung PHP codes mo wla naman akong nakikitang mali.

try mo nga to:

HTML


<form method="post" enctype="multipart/form-data">
<input type="file" name="fileImage" />
<input type="submit" value="Upload Image" name="upload" />
</form>


PHP




if (isset($_POST['upload'])) {

$path = "files/";

if(!empty($_FILES["fileImage"])){

$myFile = $path. basename($_FILES["fileImage"]["name"]);

$success = move_uploaded_file($_FILES['fileImage']['tmp_name'],$myFile);

if(!$success)
{
echo"Failed";
}else{
echo"Uploaded";
}

}

}
 
Try mo mag check ng directory tas mag auto create kung wala, tas check din kung existing ang file para iwas duplicate. tapos pwede mong gawan ng bagung pangalan ang file

$dir = "images/;
$image_newfile= rand(00000,99999).strtolower(substrbasename($_FILES['fileImage']['name']), strrpos(basename($_FILES['fileImage']['name']), '.') + 1));

if (!file_exists($dir))
{
mkdir($dir, 0777, true);
}
$image_newfile = $dir.$image_newfile;

if (file_exists($image_newfile))
{
unlink($image_newfile);
}

if(move_uploaded_file($_FILES['fileImage']['tmp_name'],$myFile))
{
echo "success";
}
 
ok naman TS ung PHP codes mo wla naman akong nakikitang mali.

try mo nga to:

HTML


<form method="post" enctype="multipart/form-data">
<input type="file" name="fileImage" />
<input type="submit" value="Upload Image" name="upload" />
</form>


PHP




if (isset($_POST['upload'])) {

$path = "files/";

if(!empty($_FILES["fileImage"])){

$myFile = $path. basename($_FILES["fileImage"]["name"]);

$success = move_uploaded_file($_FILES['fileImage']['tmp_name'],$myFile);

if(!$success)
{
echo"Failed";
}else{
echo"Uploaded";
}

}

}

Sir ok naman po tong code nyo and pumapasok sa directory yung uploaded img, hmm ano kaya problema nitong akin walang pumapasok sa upload folder ko :(
 
baka dun sa bandang form tags mo. wala ka in-include na form tags dun sa nai-paste mo kaya hindi din makapag-conclude kung saan nga nagkaroon ng problema
 
baka dun sa bandang form tags mo. wala ka in-include na form tags dun sa nai-paste mo kaya hindi din makapag-conclude kung saan nga nagkaroon ng problema

eto po yung code ko sa form sir

Code:
<!--Modal-->

	<div class="modal fade" id="myModal" role="dialog">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">×</button>
					<h4 class="moda-title">Add Employee</h4>
				</div>
				<div class="modal-body">

					<form action="insert.php" method="post" enctype="multipart/form-data">
					
						<div class="form-group">
							<label for="name">Enter Name</label>
								<div class="input-group">
									<div class="input-group-addon">
										<span class="glyphicon glyphicon-user"></span>
									</div>
									<input class="form-control" placeholder="username" name="username" type="text"></input>
								</div>
						    </div>

						<div class="form-group">
							<label for="section">Enter Section</label>
								<div class="input-group">

								<select name="section">
							        <option value="RAW">RAW</option>
							        <option value="SmackDown">SmackDown</option>
							        <option value="WWE">WWE</option>
							        <option value="WWF">WWF</option>
							  </select>
						</div>
						</div>
						<div class="form-group">
						   <label for="img">Upload Image</label>
							<div class="input-group">
								<input type="file" name="image">
						    </div>
						</div>
						<br />		
						<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-user">Add</span></button>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
				</div>
			</div>
		</div>
	</div>
 
Last edited:
Paki Post nga TS yung directory structure mo.
 
tanggalin mo muna ung header na line tapos var_dump mo ung $_FILES
mag error reporting k din.
 
<!--Modal-->
<div id="success"></div>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="moda-title">Add Employee</h4>
</div>
<div class="modal-body">
<form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
<div class="form-group">
<label for="name">Enter Name</label>
<div class="input-group">
<div class="input-group-addon">
<span class="glyphicon glyphicon-user"></span>
</div>
<input class="form-control" placeholder="username" name="username" type="text"></input>
</div>
</div>
<div class="form-group">
<label for="section">Enter Section</label>
<div class="input-group">
<select name="section">
<option value="RAW">RAW</option>
<option value="SmackDown">SmackDown</option>
<option value="WWE">WWE</option>
<option value="WWF">WWF</option>
</select>
</div>
</div>
<div class="form-group">
<label for="img">Upload Image</label>
<div class="input-group">
<input type="file" id="images" name="images[]">
</div>
</div>
<input type="hidden" name="submitted" id="submitted" value="1">
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-user">Add</span></button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
var myform = $("form");
myform.ajaxForm({
type: "POST",
url: "insert.php",
data: myform.serialize(),
success: function(response) {
$('#success').html(response);
myform.resetForm();
$('.modal').modal('hide');
},
error: function(jqXHR, textStatus, errorThrown) {
$('#success').html(response);
myform.resetForm();
$('.modal').modal('hide');
}
});
</script>
 
Maraming salamat po sa lahat ng nagrespond na ayos ko na po. Godbless! Balang araw gagaling din ako hehe para makatulong din sa iba. Ty ng madami
 
Status
Not open for further replies.
Back
Top Bottom