473,769 Members | 5,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uploading with permissions help

hi

Firstly i am working with php in an enviroment that supports unix-like
permission in an accademic environment.

The problem is enabling my script to upload a image file to my home folder,
called say photoFinalDesti nation.

so far i have set up my groups to 'www' with read, write and execute
permissions on the folder photoFinalDesti nation from within unix

my php script is the template from php.net obviously modified for my
filenames and stuff.

<?php
// In PHP earlier then 4.1.0, $HTTP_POST_FILE S should be used instead of
// $_FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_fil e()
// instead of move_uploaded_f ile

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];

print "<pre>";
if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES );
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES );
}
print "</pre>";

?>I can definatly upload to the temprary file on the server but i cannot
'move_uploaded_ file()' to my folder photoFinalDesti nation.The version of PHP
is 4.3.3 and its running on a apache server.Any and all help
appreciated.sea n
Jul 17 '05 #1
1 2262
"sean" <so*****@micros oft.com> wrote in message news:<bp******* ***@dulnain.sti r.ac.uk>...
hi

Firstly i am working with php in an enviroment that supports unix-like
permission in an accademic environment.

The problem is enabling my script to upload a image file to my home folder,
called say photoFinalDesti nation.

so far i have set up my groups to 'www' with read, write and execute
permissions on the folder photoFinalDesti nation from within unix

my php script is the template from php.net obviously modified for my
filenames and stuff.

<?php
// In PHP earlier then 4.1.0, $HTTP_POST_FILE S should be used instead of
// $_FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_fil e()
// instead of move_uploaded_f ile

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];

print "<pre>";
if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES );
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES );
}
print "</pre>";

?>I can definatly upload to the temprary file on the server but i cannot
'move_uploaded_ file()' to my folder photoFinalDesti nation.The version of PHP
is 4.3.3 and its running on a apache server.Any and all help
appreciated.sea n


Hey sean,

here is what i did to get my file upload to work...
first i check to see if all the parameters are correct...like file
size and type.

and then to actually copy the file to the destination directory i use
the following piece of code...

[PHP.
copy($HTTP_POST _FILES['file']['tmp_name'],"{directoryNam e}/".$HTTP_POST_FI LES['file']['name']);
$name = $HTTP_POST_FILE S['file']['name'];
print "File name is: " . $name;
unlink($HTTP_PO ST_FILES['file']['tmp_name']);
print "<br>File has been successfully uploaded!";
[PHP]
Hope that helps..

Karthik
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1770
by: Kenny Ashton | last post by:
Can anyone tell me how to overcome my 'permissions problems' every time I upload a new database to my ISP's server. I have a folder, specially created for me by the ISP, where I can upload new databases, read and write to those databases and create text files etc, which works fine with all my existing files and DB's. Whenever I create a new database on my 'home PC' (Windows 2000, Access 97), finish the associated ASP pages and get...
0
1153
by: FusionGuy | last post by:
I've created a file uploading handler, implemented as an httpHandler. Each time I attempt to upload a file, or files, my HttpContext.Request.Files property never contains the files that were uploaded. Here's a snippet of my handler code: // *** BEGIN HANDLER CODE *** // public class AutoUpload : IHttpHandler { public void ProcessRequest(HttpContext context) {
1
2915
by: HNguyen | last post by:
Access denied error while uploading a file to a web server. I am getting the following error while trying to upload a file to our web server: Error: Access to the path "e:\web\...\DBConnection.txt" is denied. We are working with IIS 6.0 on Windows 2003 Server running .NET Framework 1.1. To perform the upload we are using PostedFile.SaveAs(FileLocation). We have tried the following solutions: 1.. ASP.NET Machine Account has Modify,...
1
992
by: msnews.microsoft.com | last post by:
Hi Every body, I am facing the problem, while uploading the file on the server. The Erro is "Access to the path "file path" is denied." this error become when i am going to upload the file. I already have given the permission to ASPNET user on that directory. I am also useing <location> tag in web.config to allow that user on that
2
1259
by: dhnriverside | last post by:
Hi I've got a web app that I've installed on a client computer. Basically it's an intranet, and has a section where staff can upload media files for all to see, so theyre all in a conveinient place. Problem is, they want to store the media files on a diff directory, one that is OUTSIDE of the website itself. They actually want a seperate drive. I've created a virtual directory in IIS to point to that, and files are
0
1252
by: FusionGuy | last post by:
I've created a file uploading handler, implemented as an httpHandler. Each time I attempt to upload a file, or files, my HttpContext.Request.Files property never contains the files that were uploaded. Here's a snippet of my handler code: // *** BEGIN HANDLER CODE *** // public class AutoUpload : IHttpHandler { public void ProcessRequest(HttpContext context) {
1
2196
by: Nerry | last post by:
Hello everyone, I have ASP webpages, but I have a problem uploading my images via ftp, keep getting an error: An error occurred copying a file to the ftp server. Make sure you have permissions to put files on the server. Details: The operation timed out. Anyone ever had that problem? Please help! thanks.
4
29853
by: Mukesh | last post by:
Hi all I am trying to upload and save as a picture to "root/Photos" folder in my web application. I am using this code to perform this task DirectoryInfo strFolder = new DirectoryInfo("/Photos/"); if (!strFolder.Exists) { strFolder.Create(); }
11
2065
by: salmobytes | last post by:
Perhaps this is an apache server question, rather than a php question. But I want to use a simple php upload script in a user-home-sub-document-root dir on a standard linux box. If php is a mod.so it is the apache process that does the uploading, so it cannot upload into a directory that belongs to "username" unless the file permissions are 777, or perhaps......some way to use group permissions that allows the apache process to write to...
0
9589
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
10050
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
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
8876
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...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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();...
1
3967
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
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.