Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何更改froala wysiwyg中的上载路径_Php_File Upload_Image Uploading_Froala - Fatal编程技术网

Php 如何更改froala wysiwyg中的上载路径

Php 如何更改froala wysiwyg中的上载路径,php,file-upload,image-uploading,froala,Php,File Upload,Image Uploading,Froala,我正在做一个使用Froala 2.4.0所见即所得编辑器的项目。 我正在使用xampp和localhost测试。 我无法使用本地路径上载图像和文件,所有文件和图像都在以下位置上载: 但我想上传所有的文件和图像到 怎么办? 我在froala网站上试过了,但我做不到。上传图片: -在localhost中创建“uploads”目录, -在上传中创建“图像”目录, -在localhost中创建包含以下内容的php文件“upload_image.php”: <?php // Allowed exte

我正在做一个使用Froala 2.4.0所见即所得编辑器的项目。 我正在使用xampp和localhost测试。 我无法使用本地路径上载图像和文件,所有文件和图像都在以下位置上载: 但我想上传所有的文件和图像到

怎么办? 我在froala网站上试过了,但我做不到。

上传图片: -在localhost中创建“uploads”目录, -在上传中创建“图像”目录, -在localhost中创建包含以下内容的php文件“upload_image.php”:

<?php
// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png", "blob");

// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

if ((($mime == "image/gif")
|| ($mime == "image/jpeg")
|| ($mime == "image/pjpeg")
|| ($mime == "image/x-png")
|| ($mime == "image/png"))
&& in_array(strtolower($extension), $allowedExts)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/images/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/images/" . $name;
    echo stripslashes(json_encode($response));
}
   ?>
<?php
// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

$allowedExts = array(
    'pdf', 
    'doc', 
    'docx', 
    'xls', 
    'xlsx'
);

$allowedMimeTypes = array(
    'application/x-pdf', 
    'application/pdf',
    'application/msword', 
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/vnd.ms-excel', 
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
);

if (in_array(strtolower($extension), $allowedExts) AND in_array($mime, $allowedMimeTypes)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/files/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/files/" . $name;
    echo stripslashes(json_encode($response));
}
  ?>
并对文件上载重复所有步骤: -在上传中创建“文件”目录, -在localhost中创建包含以下内容的php文件“upload_file.php”:

<?php
// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png", "blob");

// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

if ((($mime == "image/gif")
|| ($mime == "image/jpeg")
|| ($mime == "image/pjpeg")
|| ($mime == "image/x-png")
|| ($mime == "image/png"))
&& in_array(strtolower($extension), $allowedExts)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/images/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/images/" . $name;
    echo stripslashes(json_encode($response));
}
   ?>
<?php
// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

$allowedExts = array(
    'pdf', 
    'doc', 
    'docx', 
    'xls', 
    'xlsx'
);

$allowedMimeTypes = array(
    'application/x-pdf', 
    'application/pdf',
    'application/msword', 
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/vnd.ms-excel', 
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
);

if (in_array(strtolower($extension), $allowedExts) AND in_array($mime, $allowedMimeTypes)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/files/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/files/" . $name;
    echo stripslashes(json_encode($response));
}
  ?>
祝你好运:)

上传图片: -在localhost中创建“uploads”目录, -在上传中创建“图像”目录, -在localhost中创建包含以下内容的php文件“upload_image.php”:

<?php
// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png", "blob");

// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

if ((($mime == "image/gif")
|| ($mime == "image/jpeg")
|| ($mime == "image/pjpeg")
|| ($mime == "image/x-png")
|| ($mime == "image/png"))
&& in_array(strtolower($extension), $allowedExts)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/images/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/images/" . $name;
    echo stripslashes(json_encode($response));
}
   ?>
<?php
// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

$allowedExts = array(
    'pdf', 
    'doc', 
    'docx', 
    'xls', 
    'xlsx'
);

$allowedMimeTypes = array(
    'application/x-pdf', 
    'application/pdf',
    'application/msword', 
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/vnd.ms-excel', 
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
);

if (in_array(strtolower($extension), $allowedExts) AND in_array($mime, $allowedMimeTypes)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/files/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/files/" . $name;
    echo stripslashes(json_encode($response));
}
  ?>
并对文件上载重复所有步骤: -在上传中创建“文件”目录, -在localhost中创建包含以下内容的php文件“upload_file.php”:

<?php
// Allowed extentions.
$allowedExts = array("gif", "jpeg", "jpg", "png", "blob");

// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

if ((($mime == "image/gif")
|| ($mime == "image/jpeg")
|| ($mime == "image/pjpeg")
|| ($mime == "image/x-png")
|| ($mime == "image/png"))
&& in_array(strtolower($extension), $allowedExts)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/images/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/images/" . $name;
    echo stripslashes(json_encode($response));
}
   ?>
<?php
// Get filename.
$temp = explode(".", $_FILES["file"]["name"]);

// Get extension.
$extension = end($temp);

// An image check is being done in the editor but it is best to
// check that again on the server side.
// Do not use $_FILES["file"]["type"] as it can be easily forged.
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES["file"]["tmp_name"]);

$allowedExts = array(
    'pdf', 
    'doc', 
    'docx', 
    'xls', 
    'xlsx'
);

$allowedMimeTypes = array(
    'application/x-pdf', 
    'application/pdf',
    'application/msword', 
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/vnd.ms-excel', 
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
);

if (in_array(strtolower($extension), $allowedExts) AND in_array($mime, $allowedMimeTypes)) {
    // Generate new random name.
    $name = sha1(microtime()) . "." . $extension;

    // Save file in the uploads folder.
    move_uploaded_file($_FILES["file"]["tmp_name"], getcwd() . "/uploads/files/" . $name);

    // Generate response.
    $response = new StdClass;
    $response->link = "http://localhost/uploads/files/" . $name;
    echo stripslashes(json_encode($response));
}
  ?>

祝你好运:)

解决方案不错!这对我来说很有效,但是,如果你不介意的话,你会有类似的视频解决方案吗?谢谢。很好的解决方案!这对我来说很有效,但是,如果你不介意的话,你会有类似的视频解决方案吗?谢谢