简体   繁体   English

Laravel 4.2奇怪的路由问题

[英]Laravel 4.2 strange routing issue

Basically, I tried to upload a file and after the app created a folder inside public, every action routed me to localhost/videos. 基本上,我尝试上传文件,并且在应用程序在public内创建文件夹之后,所有操作都将我路由到localhost / videos。 Then whenever I delete the folder it created, the behavior reverts to normal. 然后,每当我删除它创建的文件夹时,行为都会恢复为正常。 How can creating a folder inside public which isn't even in the app folder mess up the routing? 如何在public内创建一个甚至不在app文件夹中的文件夹,从而弄乱路由? I am using Laravel 4.2 and PHP 5.5.10. 我正在使用Laravel 4.2和PHP 5.5.10。

This is what I did: 这是我所做的:

$filename = date('Y-m-d-H:i:s')."-".$client_file_name;
$destinationPath = base_path() . '\public\uploaded_video';
Input::file('post')->move($destinationPath, $filename);

the second line messes up the routing and then everything becomes back to normal when I delete the folder. 第二行弄乱了路由,然后当我删除文件夹时一切恢复正常。 Is it because I am running on Windows or something? 是因为我在Windows或其他操作系统上运行? I tried doing '/public/uploaded_video' instead, but I think it didn't work. 我尝试改用'/ public / uploaded_video',但我认为这没有用。

Actually any_Path function returns the local path on the server but you need a url so in this case, you may try something like this: 实际上any_Path函数返回服务器上的本地路径,但是您需要一个url因此在这种情况下,您可以尝试执行以下操作:

$destinationPath = asset('uploaded_video');

More on Laravel website . 有关Laravel网站的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM