473,698 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file upload permission error

wadro21
12 New Member
i am trying to write a php uploader for a site and keep getting this error:
Expand|Select|Wrap|Line Numbers
  1. Warning: move_uploaded_file(uploads61877494_tp.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/mysite/public_html/login/upload.php on line 5
  2.  
  3. Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpKlOJBh' to 'uploads61877494_tp.jpg' in /home/mysite/public_html/login/upload.php on line 5
  4.  
I can run it fine on my local machine but when i upload it to the webserver it errors out. here is some example code:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. // Connects to Database 
  3. mysql_connect("localhost", "__MUNGED__", "__MUNGED__") or die(mysql_error()); 
  4. mysql_select_db("mysite_admin") or die(mysql_error());; 
  5.  
  6. //checks cookies to make sure they are logged in 
  7. if(isset($_COOKIE['ID_my_cookie'])) 
  8. $username = $_COOKIE['ID_my_cookie']; 
  9. $pass = $_COOKIE['Key_my_cookie']; 
  10. $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
  11. while($info = mysql_fetch_array( $check )) 
  12.  
  13. //if the cookie has the wrong password, they are taken to the login page 
  14. if ($pass != $info['password']) 
  15. { header("Location: login.php"); 
  16.  
  17. //otherwise they are shown the admin area 
  18. else 
  19. {
  20. echo "Admin Area<p>"; 
  21. echo "<a href=logout.php>Logout</a>";
  22. ?>
  23.  
  24. <fieldset>
  25.    <legend>File Upload</legend>
  26.    <p>
  27.  
  28.    <form enctype="multipart/form-data" action="upload.php" method="POST">
  29. Please choose a file: <input name="uploaded" type="file" /><br />
  30. <input type="submit" value="Upload" />
  31. </form> 
  32.  
  33.    </p>
  34.    </fieldset>
  35. ?>
  36.  
  37. upload.php
  38. <?php 
  39. $target = "uploads"; 
  40. $target = $target . basename( $_FILES['uploaded']['name']) ; 
  41. $ok=1; 
  42. if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
  43. {
  44. echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
  45. else {
  46. echo "Sorry, there was a problem uploading your file.";
  47. }
  48.  
  49. if ($uploaded_size > 350000)
  50. {
  51.  
  52.  
  53. echo "Your file is too large.<br>"; 
  54. $ok=0;
  55. ?>
  56.  
Aug 27 '07 #1
1 1827
Atli
5,058 Recognized Expert Expert
Hi.

This is not a problem with your code. This happens because you do not have permission to access the files you are trying to move.

Make sure you edit the permission on the folder you are moving your file into so that your script can write into it.

Also, use [code] tags when posting code. It is barely readable without them.
Aug 28 '07 #2

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

Similar topics

3
3565
by: kafooey | last post by:
Hi all, I've been digging around on the newsgroups and the web for a possible answer for this problem, but have so far come up with nothing so thought I would ask here... I have the following code doing a file upload... $upload_result =
1
3273
by: igotyourdotnet | last post by:
Ok, here is the issue: I have 2 web pages one does a file upload to a database and the other page does a FTP to a server, both pages use the c:\temp directory. The page that uploads to a database works fine, the page that FTP's the files returns me an error (Access denied filename.txt) Now the asp.net ID has full control of the c:\temp directory. The only difference in the 2 pages is that page 2 creates a text file writes data to it then...
3
23075
acoder
by: acoder | last post by:
How to Upload a File in Coldfusion Use the cffile tag for uploading files to the server. Note that allowing people to upload files is fraught with danger and only trusted users should be allowed to upload files. Checks should be made to make sure that only allowed file types are uploaded. The Client-Side First of all, let us deal with the client side. This assumes some knowledge of HTML.
3
3581
by: Ethan Strauss | last post by:
Hi, I have a C#.Net 2.0 web app which needs to be able to read a bunch of files from a user's computer, but I have not be able to get it to do so without "Access denied" errors. The main piece of code is simple List<FileInfoAllFiles = new List<FileInfo>(); System.Security.Permissions.FileIOPermission MyPermissions = new System.Security.Permissions.FileIOPermission System.Security.Permissions.FileIOPermissionAccess.AllAccess,
4
10547
by: Tony B | last post by:
I've moved an existing site (which I didn't write) from a apache/php/mysql host under windows to a linux apache/php/mysql host. I've sorted out most problems except one. There is an upload function on the site, which uploads files via POST to temp folder and then moves it into a folder on the host using php function move_uploaded_file. Under windows this works fine but on the linux host the uploaded file is created with 600 permissions so...
1
1889
by: lPrentice | last post by:
Hello, After all this time, Linux file permissions still confuse me at times. I have a Python web-based application with an file (images) upload module. The application is running on two remote servers and a local server on my development network. The upload module works just fine when I'm uploading to my remote servers. But when I try to upload to my development server, I get a permission error. What I don't understand is who is...
6
3832
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the network should be able to connect to the database and run queries on the database or upload new music that does not yet exist on the database. The uploaded file's name should be in the following format: ARTIST - TITLE.mp3. I have the code to upload images,...
3
1940
by: wassimdaccache | last post by:
Dear sirs, It is shame to me to say that I have been 1 week working in this problem and it is not working. I am getting this error while I am uploading a file using my website. Warning: copy( /home/wasstech/attachement/juj.doc) : failed to open stream: Operation not permitted in /home/wasstech/public_html/send.php on line 9 Error
5
6807
by: kailashchandra | last post by:
I am trying to upload a file in php,but it gives me error msg please Help me? My Code is like below:- i have one php file named upload.php and i have another html file named upload.html and inside html i am calling php file upload.php:- <?php
0
8674
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
8604
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,...
0
9028
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
8895
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
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
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
6518
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
4369
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...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.