我正在尝试将一个MP3文件上传到Laravel应用程序并遇到一个问题,即使该文件的属性设置为"audio/mpeg",它也会上传为"application/octet-stream"(.bin)文件.当我尝试死亡并将文件转储到服务器端代码时:
dd($request->file('file'));
Run Code Online (Sandbox Code Playgroud)
我明白了:
UploadedFile {#187 ?
-test: false
-originalName: "CUS12309821-20-AUG-2016-13-48-13.mp3"
-mimeType: "audio/mpeg"
-size: 47000471
-error: 0
path: "/private/var/folders/c7/6ws0lxy95dd_lhz1k067_zkc0000gn/T"
filename: "phpyZCsbU"
basename: "phpyZCsbU"
pathname: "/private/var/folders/c7/6ws0lxy95dd_lhz1k067_zkc0000gn/T/phpyZCsbU"
extension: ""
realPath: "/private/var/folders/c7/6ws0lxy95dd_lhz1k067_zkc0000gn/T/phpyZCsbU"
aTime: 2016-09-20 12:56:00
mTime: 2016-09-20 12:56:00
cTime: 2016-09-20 12:56:00
inode: 4565593
size: 47000471
perms: 0100600
owner: 501
group: 20
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
Run Code Online (Sandbox Code Playgroud)
看看我何时使用这种方法,确实说mimeType的文件属性是正确的"audio/mpeg"格式.但是当我上传文件后调用getMimeType()方法时,我得到:
"application/octet-stream"
Run Code Online (Sandbox Code Playgroud)
这是路由方法中的代码:
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用PHP创建一个Web服务,以便与应用程序进行通信,从数据库获取数据并将其转换为应用程序的XML格式.但是,其中一列包含HTML,需要输出(我认为)作为CDATA.虽然我很难完成这个.请指教
<?php
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME);
$sql = "SELECT post_date_gmt, post_content, post_title FROM [schema].wp_posts WHERE post_status = \"publish\" && post_type = \"post\" ORDER BY post_date_gmt DESC;";
$res = mysql_query($sql);
$xml = new XMLWriter();
$xml->openURI("php://output");
$xml->startDocument();
$xml->setIndent(true);
$xml->startElement('BlogPosts');
while ($row = mysql_fetch_assoc($res)) {
$xml->startElement("Post");
$xml->startElement("PostDate");
$xml->writeRaw($row['post_date_gmt']);
$xml->endElement();
$xml->startElement("PostTitle");
$xml->$writeRaw($row['post_title']);
$xml->endElement();
$xml->startCData("PostContent");
$xml->writeCData($row['post_content']);
$xml->endCData();
$xml->endElement();
}
$xml->endElement();
header('Content-type: text/xml');
$xml->flush();
?>
Run Code Online (Sandbox Code Playgroud)
非常感谢您提供的任何帮助!