dongqing8765 2015-01-21 06:39
浏览 61

PHP copy()是否可以使用两台客户端PC?

I'm using two computers (both connected to one network) and one of them has XAMPP. I'm trying to upload files to the one with XAMPP in it (the files are from the other computer). But I always end up having the 'No such file or directory' error even though I have the correct path. But when I use the path from the computer with XAMPP, even when I'm using the other computer, the system works just fine. Can anyone help me?

P.S. I'm using PHP copy() function because the file path is coming from an excel file.

Here's the part of my PHP code:

$original_file_name = objWorksheet->getCellByColumnAndRow(5,$i)->getValue();
// Example of the cell value: C:\Users\ComputerWithoutXAMPP\Desktop\scanned documents\SO 2010\#1.jpeg

$ext = pathinfo($original_file_name, PATHINFO_EXTENSION);
$file = time().substr(md5(microtime()),rand(0,26),5);
// UPLOAD THE FILE DECLARED IN EXCEL
copy($original_file_name, 'uploads/docs/'.$file.'.'.$ext);
  • 写回答

1条回答 默认 最新

  • dongpao5261 2015-01-21 07:22
    关注

    You can use copy() to upload a file to another machine, or from another machine, but to access the remote machine, the appropriate argument to copy (source or dest) has to be a URL. The code you've posted is trying to copy the file to a local "uploads/docs/" directory, it's doesn't even appear to aware of another machine.

    While what you're looking to do may be technically possible, I haven't the foggiest idea how you'd go about it: it seems rather Rube Goldberg to me. The ftp:// wrapper would probably work, if FTP is set up properly on the XAMPP server.

    How big is the file you're trying to send? If it's small enough, you may have better luck either encoding and sending the content itself or uploading the file with curl to an upload-catching script on the XAMPP side

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?