我無法上傳文件到uploads文件夾。我沒有使用公共文件夾,我刪除了公共文件,並在根導向器中移動了我爲Laravel創建的文件夾。如何在laravel5上傳文件並獲取上傳文件中的文件
app
bootstrap
config
css
database
fonts
images
storage
tests
vendor
uploads
.env
.htaccess
index
我AashishController.php
<?php
namespace App\Http\Controllers;
use Input;
use Mail;
class AashishController extends Controller
{
public function index()
{
return view('in');
}
public function contact()
{
return view('contact');
}
public function postcontact()
{
$name = \Input::get('name');
$email = \Input::get('email');
$phone = \Input::get('phone');
$message1 = \Input::get('message');
$file1 = Input::file('file1');
$userr=$file1;
//Create directory if it does not exist
if(!is_dir("uploads/".$userr."/")) {
mkdir("uploads/".$userr."/");
}
// Move the uploaded file
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/".$userr."/". $_FILES["file"]["name"]);
$to ="[email protected]";
$subject = "hi";
$mail_body = '<html>
<body bgcolor="#573A28" topmargin="25">
Put HTML content here with variables from PHP if you like
Variable display Example:
</body>
</html>';
$headers = "From:[email protected]";
$headers .= "Content-type: text/html";
mail($to, $subject, $mail_body, $headers);
return view('test')->with('name', $name);
}
}
如何從該目錄下的文件,並把它傳遞給看法?
HTTP://msaashish.wc。lt /檢查現場url的錯誤 – 2015-04-04 16:42:59
你可以編輯我的控制器並粘貼它 – 2015-04-04 16:50:52
你可以粘貼完整的控制器 – 2015-04-04 16:53:56