这是一些将文件发送到ftp的生产代码(对于您来说可能是一个很好的解决方案):
// This is the entire file that was uploaded to a temp location.$localFile = $_FILES[$fileKey]['tmp_name'];$fp = fopen($localFile, 'r');// Connecting to website.$ch = curl_init();curl_setopt($ch, CURLOPT_USERPWD, "email@email.org:password");curl_setopt($ch, CURLOPT_URL, 'ftp://@ftp.website.net/audio/' . $strFileName);curl_setopt($ch, CURLOPT_UPLOAD, 1);curl_setopt($ch, CURLOPT_TIMEOUT, 86400); // 1 Day Timeoutcurl_setopt($ch, CURLOPT_INFILE, $fp);curl_setopt($ch, CURLOPT_NOPROGRESS, false);curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'CURL_callback');curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localFile));curl_exec ($ch);if (curl_errno($ch)) { $msg = curl_error($ch);}else { $msg = 'File uploaded successfully.';}curl_close ($ch);$return = array('msg' => $msg);echo json_enpre($return);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)