简体   繁体   English

无法在服务器上上传文件

[英]can't upload file on server

I am trying use this example http://www.sajithmr.me/jrecorder/example2.html for recording audio and send it to my localhost server, but I have issue here. 我正在尝试使用此示例http://www.sajithmr.me/jrecorder/example2.html录制音频并将其发送到我的本地主机服务器,但是这里有问题。 My code describe below 我的代码描述如下

<script>

   $.jRecorder(

     { 
        host : 'http://localhost/Jrec/html/acceptfile.php?filename=hello.wav',  
        callback_started_recording:     function(){callback_started(); },
        callback_stopped_recording:     function(){callback_stopped(); },
        callback_activityLevel:          function(level){callback_activityLevel(level); },
        callback_activityTime:     function(time){callback_activityTime(time); },
        callback_finished_sending:     function(time){ callback_finished_sending() },
        swf_path : 'jRecorder.swf',

     }
   );
   </script>

this my acceptfile.php 这是我的acceptfile.php

      if(!isset($_REQUEST['filename']))
   {
     exit('No file');
   }

   $upload_path = dirname(__FILE__). '/';

   $filename = $_REQUEST['filename'];

   $fp = fopen($upload_path."/".$filename.".wav", "wb");

   fwrite($fp, file_get_contents('php://input'));

   fclose($fp);

   exit('done');

whalt should I do with $upload_path = dirname( FILE ). 我应该用$ upload_path = dirname( FILE )做些什么。 '/;? '/ ;?
when I press send data button the file doesn't upload into following directory ("files"). 当我按下发送数据按钮时,文件不会上传到以下目录(“文件”)。 What is the problem here, Any help will be apriciated 这是什么问题,将不胜感激

it works like Shikiryu and seth flowers said. 它的工作方式像Shikiryuseth flowers所说。 But remember to remove .wav from filename because it adds the extension .wav here: $fp = fopen($upload_path."/".$filename.".wav", "wb"); 但是请记住从文件名中删除.wav,因为它在此处添加了扩展名.wav: $fp = fopen($upload_path."/".$filename.".wav", "wb");

Also note the 2 forward-slashes "/" concatenated in the filepath variable $fp . 另请注意,在文件路径变量$fp串联了两个正斜杠“ /”。

  • 1st from $upload_path 来自$upload_path
  • 2nd from $fp $fp第二名

This assumes you will create a folder in your directory to store the sound file. 假设您将在目录中创建一个文件夹来存储声音文件。

$fp = fopen($upload_path."NAME_OF_FOLDER/".$filename.".wav", "wb");

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

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