473,378 Members | 1,498 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,378 software developers and data experts.

Warning: file_put_contents(): failed to open stream:

I'm just started learning Programming and have tryed to create a Drag and Drop upload form. The problem that I am having is that when I drag and drop a file on to my drop area I receive a post code of 200 which show that its ok. After checking my upload directory the file was not uploaded and I have an error of:

Warning: file_put_contents(../../../media/SeagateHDD/Uploads/): failed to open stream: Is a directory in /var/www/PHP/Drop_Upload.php on line 10. File Uploaded Successfully

I belive that this means that my upload path is not correct
but I have check four times and the path is correct. I then changed the permissions to 777 and still get the same 200 code with error. Can anyone help me?

My Jquery is:
Expand|Select|Wrap|Line Numbers
  1. $(function(){
  2.  
  3.     var obj = $('#Upload_form');
  4.  
  5.     obj.on('dragover', function(e){
  6.         //prevent browser from open the file when drop off
  7.         e.stopPropagation();
  8.         e.preventDefault();
  9.         $(this).css('border',"3px solid #000000");
  10.     });
  11.  
  12.     obj.on('dragleave', function(e){
  13.         //prevent browser from open the file when drop off
  14.         e.stopPropagation();
  15.         e.preventDefault();
  16.         $(this).css('border',"3px dashed #4a4a4a");
  17.     });
  18.  
  19.     obj.on('drop',function(e){
  20.         //prevent browser from open the file when drop off
  21.         e.stopPropagation();
  22.         e.preventDefault();
  23.         $(this).css('border',"3px dashed #4a4a4a");
  24.  
  25.         //retrieve uploaded files data
  26.         var files = e.originalEvent.dataTransfer.files;
  27.         var file = files[0];
  28.  
  29.         upload(file);
  30.     });
  31.  
  32.     function upload(file){
  33.         xhr = new XMLHttpRequest();
  34.  
  35.         //initiate Request
  36.         xhr.open('post','../PHP/Drop_Upload.php');
  37.  
  38.         //set headers
  39.         xhr.setRequestHeader('Content-Type', "multipart/form-data");
  40.         xhr.setRequestHeader('X-File-Name',file.fileName);
  41.         xhr.setRequestHeader('X-File-Size',file.fileSize);
  42.         xhr.setRequestHeader('X-File-Type',file.fileType);
  43.  
  44.         //send the file
  45.         xhr.send(file);
  46.     }
  47. });
  48.  
  49. And my PHP is:
  50. <?php
  51.  
  52. $string =file_get_contents('php://input');
  53. $path = '../media/SeagateHDD/Uploads/';
  54.  
  55. if ( !file_exists($path) ) {
  56.   mkdir ($path, 0777);
  57.  }
  58.  
  59. file_put_contents($path,$string);
  60.  
  61. echo 'File Uploaded Successfully';
Feb 18 '15 #1
0 4056

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

Similar topics

1
by: sa | last post by:
Trying to upload a file using win xp/iis/php. I've given full access to all accounts trying to get this to work? Yet I'm still getting read errors. Simplified the script below to the bare...
0
by: crescent_au | last post by:
Hi all, I am having problem with the file() function. In my code, I have file() function like this: $url =...
9
by: One | last post by:
I have a main.php file that calls a php navigation menu. I want to pass the menu file a parameter to tell it which menu to display. Inside the main.php I have : include...
1
by: kencana | last post by:
Hi all, I was wondering why I always get "failed to open stream: HTTP request failed!" error in either loading a normal or xml file. i don't understand why i can't get the whole result. the result...
2
by: simbarashe | last post by:
Hie I'm trying to pass variables between pages using URLs however I am encountering the following error when I do so: Warning: main(jobSheetDisplay.php?id=20071403PB136CoA) : failed to open...
3
by: siyaverma | last post by:
i am trying to upload csv file from user's computer to main server the code i am using is if(((isset($_GET)) && ($_GET=="yes")) ) { $typefield = $_GET; echo...
6
by: Andy2500 | last post by:
Hi, I'd like to upload an image to a folder, then I have 3 diffrents examples but all of them give an error "failed to open stream: Permission denied", althrough the C:\Inetpub\wwwroot is not...
5
by: tyakimov | last post by:
Hi guys I got a problem On my IIS server I changed the password for the Internet Guest Account 'IUSR_Machine' and suddenly the PHP part of the intranet stopped working. - '... failed to open...
0
by: sleepybutterfly | last post by:
Hi, I've been work for file download at remote server by using fopen function but i get the error : Warning: fopen(/a/b/song.mp3) : failed to open stream: No such file or directory ...
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.