我正在做我的学校项目,我们使用 Winscp 作为服务器。所以我是 php 的新手,尝试处理图像上传,我读过很多文章说我需要编辑我的 php.ini 文件并将 file_uploads 指令设置为“on”。但我只是不知道我的 php.ini 文件在哪里。
这是我的 phpinfo.php 链接:http ://cgi.sice.indiana.edu/~baehy/phpinfo.php 所以它说我的 php.ini 在 /etc/php.ini 而我在我的网站上找不到它电脑(我知道这听起来很傻)
每条评论都值得赞赏!谢谢大家!
这是我的代码
<?php
session_start();
include('database.php');
ini_set('max_exection_time', 60);
if(!isset($_SESSION['userid'])){
header('location: http://cgi.sice.indiana.edu/~baehy/team72index.php');
} else {
echo "Welcome " . $_SESSION['userid'] . "<br>";
if(isset($_POST['submit'])){
$title = $_POST['title'];
$category = $_POST['category'];
$description = $_POST['description'];
//get file from the form and get following information
$file = $_FILES['coverimage'];
$fileName = $_FILES['coverimage']['name'];
$fileTmpName = $_FILES['coverimage']['tmp_name'];
$fileSize = $_FILES['coverimage']['size'];
$fileError = $_FILES['coverimage']['error'];
$fileType = $_FILES['coverimage']['type'];
//retrieve file extention using explode()
$fileExt = explode('.', $fileName);
//because some file extentions might be in capital letters
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg','jpeg','png');
if(in_array($fileActualExt, $allowed)){
if($fileError === 0){
//if the size of the file is lesser than 1M kb = 1000mb
if($fileSize < 1000000){
$fileNameNew = uniqid('',true).".".$fileActualExt;
chmod('uploads/',0777);
echo "permission granted to uploads directory!" . "<br>";
$fileDestination = 'uploads/'.$fileNameNew;
move_uploaded_file($fileTmpName, $fileDestination);
echo $fileNameNew . "<br>";
echo "Successfully uploaded your file" . "<br>";
} else {
echo "Your file is too big to upload" . "<br>";
}
} else {
echo "There was an error uploading your file" . "<br>";
}
ps,我还需要将文件夹的绝对路径('uploads')放在代码中才能使用它吗?谢谢!
芜湖不芜
呼如林