1

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);
user3213531
  • 43
  • 1
  • 1
  • 8

1 Answers1

0

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

Community
  • 1
  • 1
GeminiDomino
  • 451
  • 1
  • 5
  • 19
  • I tried using my other computer's IP address instead of the C:\Directory format and it worked fine. The source folder should be shared with the computer with XAMPP though. – user3213531 Jan 27 '15 at 06:00
  • Shared as in a Windows/SMB share? Then using the local mapping should work fine. There are too many missing details for your setup for me to picture what's going on, though. You might try some breadcrumb debugging with is_dir() and the like to see where it's falling apart. – GeminiDomino Jan 27 '15 at 18:45