I'm a student making a simple file upload page with PHP.
But it doesn't work when I upload the actual file on the form and submit it.
I need some help to find what is gone wrong.
uploadProfilePicture.php (I used some bootstrap components)
<?php
session_start();
header('Content-Type: text/html; charset=utf-8');
?>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Change profile picutre</title>
<link rel="stylesheet" href="../../../css/font.css">
<link rel="shortcut icon" href="../../../favicon/favicon.ico">
<link rel="stylesheet" href="./css/uploadProfilePicture.css">
</head>
<?php include('../../../common/resource.html'); ?>
<body>
<div id="content">
<h3 id="title">Change Profile Picutre</h3>
<form id="profileImageUploadForm" method="POST" action="processProfileImage.php" enctype="multipart/form-data">
<label for="formFile" class="form-label">Upload your image!</label>
<input type="file" class="form-control" id="formFile">
<input class="button-30" role="button" type="submit"></input>
</form>
</div>
</body>
</html>
processProfileImage.php
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Change profile picutre</title>
<link rel="stylesheet" href="../../../css/font.css">
<link rel="shortcut icon" href="../../../favicon/favicon.ico">
<link rel="stylesheet" href="./css/uploadProfilePicture.css">
</head>
<body>
</body>
</html>
<?php
session_start();
header('Content-Type: text/html; charset=utf-8');
var_dump($_FILES);
var_dump($_POST)
?>
When I tried to check $_FILES and $_POST, only void arrays returned and I couldn't find what was wrong. I think there's been a mistake in a small part, but I haven't dealt with PHP a lot, so I don't have a good sense of it.
If you have identified the problem with this code, please let me know. Thanks.
Related
I want to apply color to a text using tailwindcss but it's not working.
Here is the code-
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="output.css" rel="stylesheet">
</head>
<body>
<h1 class="text-yellow-400 font-bold">
Hello, world!
</h1>
</body>
</html>
This is what that looks like in the browser. It seems like the class is not being applied.
Try to add Tailwind with the CDN because maybe output.css doesn't contain the feature you want to use.
```html
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<h1 class="text-yellow-400 font-bold">
Hello world!
</h1>
</body>
</html>
```
I don't understand how this happen.
In my index.php, i require the page header.php :
<?php require("view/viewHeader.php");
Which contains this :
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Mon systeme</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="css/global.css" />
</head>
<body>
<div id="content">
So how i get this on the final page ?
link outside the head
The index.php has 165 lines, so i show you the beginning of the switch where the require call the viewHeader.php :
switch ($action) {
case 'ajout':
$menuTitre = "Ajout";
require("view/viewHeader.php");
require("view/viewMenuEnTete.php");
require("view/viewAjout.php");
require("view/viewFooter.php");
break;
Yes in the source it is alright
<div id="debug">ACTION: string(5) "ajout"
<br/>RECH: NULL
<br/><hr />POST<br/>array(1) {
["action"]=>
string(5) "ajout"
}
<hr /></div><!DOCTYPE html>
<html lang="fr">
<head>
<title>Mon systeme</title>
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="css/global.css" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="content">
But the manifest is not detected. I thought there were a problem with the head mixed up.
I get rid of the small div in top, but it doesn't change anything :(
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Mon systeme</title>
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="css/global.css" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="content">
When I query in MySQL then it returns in Japanese Character. An image is attached below.
But in browser its shown "????". An image is attached below.
Here I enclose my base.html code.
<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link media="screen" href="<?php echo $this->path_to('/common/css/import.css') ?>" type="text/css" rel="stylesheet" />
<script src="<?php echo $this->path_to('/common/js/jquery-2.1.0.min.js') ?>"></script>
<title><?php echo $this->v('page_title') ?></title>
</head>
<body>
<?php echo $this->part_of('body') ?>
</body>
</html>
Use mysqli_set_charset($db,'utf8'); in your dbconnection file. in my case $db is my connection variable
When I use pgp require it moves the head content on the included file into the body tags, I've explored questions somewhat related to my problem but none have solved my problem.
index.php:
<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>
<?php
require '/home/sethfreeman/public_html/subdomains/gwd/navigation/header/header.html';
?>
Included File:
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://sethjfreeman.com/subdomains/gwd/assets/css/header.css" type="text/css">
<link rel="stylesheet" href="http://sethjfreeman.com/subdomains/gwd/assets/libs/bootstrap/css/bootstrap.css" media="screen">
<link rel="stylesheet" href="http://sethjfreeman.com/subdomains/gwd/assets/libs/bootstrap/css/bootstrap-responsive.css" media="screen">
</head>
<body>
<div class="container"></div>
<script src="http://sethjfreeman.com/subdomains/gwd/assets/js/jquery-3.1.1.js"></script>
<script src="http://sethjfreeman.com/subdomains/gwd/assets/libs/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
Chrome Output:
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://sethjfreeman.com/subdomains/gwd/assets/css/header.css" type="text/css">
<link rel="stylesheet" href="http://sethjfreeman.com/subdomains/gwd/assets/libs/bootstrap/css/bootstrap.css" media="screen">
<link rel="stylesheet" href="http://sethjfreeman.com/subdomains/gwd/assets/libs/bootstrap/css/bootstrap-responsive.css" media="screen">
<div class="container"></div>
<script src="http://sethjfreeman.com/subdomains/gwd/assets/js/jquery-3.1.1.js"></script>
<script src="http://sethjfreeman.com/subdomains/gwd/assets/libs/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
"Require isn't smart. It's simply going to dump the contents of the required file where it's invoked. If you want some code in the head portion, put that in a separate file and require it in the correct place." - Major Productions LLC
To close this question.
I have a problem with including a php file
PagePrevie.php :
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="Style/css/bootstrap.min.css" />
<script src="Style/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="Style/css/Header-Picture.css">
<link rel="stylesheet" href="Style/css/Footer-with-logo.css">
<title></title>
</head>
<body class="container lg-warning">
<?php
include 'include/LogoUMBB.php';
include 'include/Header.php';
?>
<div class="container bg-success text-primary" style="width:500px;padding: 20px;">
</div>
<br />
<?php
include 'include/Footer.php';
?>
</body>
</html>
The problem is that this file is located in a directory that contains other web page with the same code
And here is the structure of files:
PHP told you your path is incorrect, add "../" so you get correct include path.
include '../include/LogoUMBB.php';
include '../include/Header.php';
include '../include/Footer.php';