473,320 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

copy file from a directory(outside webroot) to another directory

11
hi all,
I am not able to copy file from a directory in the server to another directory.
Here,
the source is outside the web root directory and the destination is inside the web root directory.

I got a warning
Warning: copy(http://localhost/files/../../fileUploads/photo1.JPG) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in D:\wamp\www\files\test.php on line 3
The code is as follows:
Expand|Select|Wrap|Line Numbers
  1. $destination="http://localhost/files/fileUploads/photo1.JPG";
  2. $source="http://localhost/files/../../fileUploads/photo1.JPG";
  3. copy($source, $destination);
  4.  
  5.  
Jan 20 '09 #1
2 4694
Dormilich
8,658 Expert Mod 8TB
well, yes.... you cannot access files outside the server root (it's a security measure). the only chance is trying to execute a shell command (or whatever it is called in windows)
Jan 20 '09 #2
Markus
6,050 Expert 4TB
You could use a system path, like so:
Expand|Select|Wrap|Line Numbers
  1. $destination = "c:\xampp\htdocs\dir\file.txt";
  2. $source = "c:\xampp\secure\file.txt";
  3.  
Jan 20 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: vince | last post by:
MSDN help says you can use a UNC path for any methods that accept a path, and I'm wondering if I can also substitute an IP address for the UNC....??? Example: Using System.IO.File.Move() ...
1
by: Maurice Mertens | last post by:
Hi all, is it possible to programmatically determine the current users permissions on a file / directory? I want to check if the user can add/delete files to a folder. -- Met vriendelijke...
5
by: Aryeh Katz | last post by:
I'd like to set the permissions on a file (directory) so that a user (and only that user) is granted full control for that file. Using c++, I was able to use the BuildExplicitAccessWithName, and...
0
by: Ollie Riches | last post by:
I am executing a DTS programmatically from C# using COM interop. Is it possible to set the 'script file directory' from the C# code? For anyone else you gets an 'Access Denied Error' when...
4
by: John Blair | last post by:
Hi, Can anyone tell me how to make the Copy Project option work from within Vb.net - it fails on my PC with an error saying the new copy directory is marked as executable and i am not allowed to...
2
by: Antonio-F100 | last post by:
Hello, I need help creating the code for a macro button on a form that will open a file directory with windows explorer. I have about 500 directories with very long names and only want to...
13
by: Puja | last post by:
hi all, how can I copy directory c:\test to a directory c:\backup with all files, folders and subfolders that are contained within test. please advice! thanks
4
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. Currently file-directory-related functionality in the Python standard library is scattered among various modules such as shutil, os,...
5
by: peruron | last post by:
Hello again! I've been discussing the advantages of Python over C-Shell. I was asked if I can replace the use of "grep" in searching for a specific string in a multi-file directory - I have to go...
1
by: bnashenas1984 | last post by:
Hi everyone Does anyone know how to include a file outside the HTDOCS root? When I login to my ftp htdoc is the folder where I put my index.php but I want to put a file outside this folder and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.