473,748 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copy file from a directory(outsi de webroot) to another directory

11 New Member
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\fil es\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 4730
Dormilich
8,658 Recognized Expert Moderator Expert
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 Recognized Expert Expert
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
3497
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() File.Move("\\\\MyServer\\share\\dir\\myfile.txt", "\\\\YourServer\\share\\dir\\myfile.txt");
1
1466
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 groet / With regards / Saludos, Moviat Automatisering
5
2804
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 SetEntriesInAcl calls. Is there a native c# way to do this? Aryeh
0
1396
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 attempting to run a DTS package from code it is because the local machine attempting to run the remote DTS package does not have the 'script file directory' defined on the local machine. Cheers
4
2145
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 copy files into that directory on my PC! thanks.
2
3097
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 input part of the directory name into the table that the form uses.
13
1190
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
1428
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, dircache etc. So I request that the functions be gathered and consolidated at one place. Some may need renaming to avoid conflicts or for clarification.
5
2590
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 through all the files, and find all the occurrences of a specific string. Can anyone suggest an idea? Thanks!
1
1222
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 include it in the index file file.php HTDOCS (folder)+ | -index.php
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.