473,761 Members | 9,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Warning: fread(): supplied argument is not a valid stream resource

2 New Member
For the below code i am getting an error like :
---------------------------------------------------------------
Warning: fread(): supplied argument is not a valid stream resource in D:\Public_Site\ multifileupload \welcome_addfil es.php on line 28
------------------------------------------------------------
i am trying many ways by giving diff arguments in fread()
---------------------------------------------------
suggest me ,
wat error ,how to rectify it.


THIS CODE IS BASICALLY TO UPLOAD A FILE TO DB AND IMG TO UPLOAD FOLDER.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $uploadDir = 'D:/localhost/multifileupload/upload/';
  4. //'mutlifileupload' if folder name where v save files in.
  5. //'upload'(to save images) is folder in 'multifileupload'.
  6.  
  7. if (($_FILES["file"]["type"] == "image/gif")
  8. || ($_FILES["file"]["type"] == "image/jpeg")
  9. || ($_FILES["file"]["type"] == "image/jpeg")
  10. && ($_FILES["file"]["size"] < 20000))
  11.   {
  12.   if ($_FILES["file"]["error"] > 0){
  13.     echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  14.     }
  15.     else  if (file_exists("upload/" . $_FILES["file"]["name"]))
  16.              {echo "Entered File:-----".$_FILES["file"]["name"] . " :-----Already exists. <BR/>";}
  17.           else
  18.             {
  19.             $filePath = $uploadDir . $fileName;
  20.  
  21.         //----------this is to store in db mysql-----------            
  22.           $lnk=mysql_connect('localhost','root','etg') or die(mysql_error());
  23.           mysql_select_db('registrationformdb',$lnk);
  24.           $sql="select * FROM registrationformdb.image ";
  25.             //'registrationformdb' is db name,'image' is table name
  26.           $photo = addslashes(fread(fopen($_FILES['upload']['tmp_name'],"r"), $_FILES['file']['size']));
  27.           $query = sprintf("INSERT INTO image(FileName) VALUES ('".$_FILES["file"]["name"]."')");    
  28.  
  29.           if (mysql_query($query)) 
  30.               {
  31.              $messages[] = "Your files is successfully store in database";
  32.              } 
  33.             else {$messages[]= mysql_error();}
  34.         //----------end this is to store  in  db mysql----------------
  35. echo "<h3>you are succesfully uploaded the file</h3><br/>";        
  36. echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  37. echo "Type: " . $_FILES["file"]["type"] . "<br />";
  38. echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";        
  39. echo "Temp file: " . $_FILES["upload"]["tmp_name"] . "<br />";    
  40.  
  41. //here v move the upload files into 'upload' folder
  42. move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
  43. echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
  44. }
  45. }
  46. else{echo "Invalid file";}
  47. ?>
Sep 20 '07 #1
2 10289
code green
1,726 Recognized Expert Top Contributor
[PHP]$photo = addslashes(frea d(fopen($_FILES['upload']['tmp_name'],"r"), $_FILES['file']['size']));[/PHP] Should 'upload' be 'file'?
Sep 20 '07 #2
pbmods
5,821 Recognized Expert Expert
Heya, Yogitha. Welcome to TSDN!

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Sep 20 '07 #3

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

Similar topics

3
3437
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array(): ============================================================== In the past i use my code/script work fine with Mandrake 9.1 - 10.1 ( + apache ,mysql ) Now i move to redhat EL4 with the same code/script
2
18903
by: 00webman | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/scripts/07/view_users.php on line 15 Can anyone spot my error?!? Thanks. <?php # Script 7.6 - view_users.php (2nd version after Script 7.4) // This script retrieves all the records from the users table. $page_title = 'View the Current Users'; include ('./includes/header.html');
3
3919
by: petemaxi | last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9 <div class="left"> <div class="menu"> <div class="boxhead" style="text-align:center;"> <strong>Menu</strong> </div> <br /> <?php require ('includes/db_conn.inc.php'); $query = "select * from menu order by item_order"; $result = mysql_query($query);
4
7836
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the fields Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34 Sorry You failed to enter the correct old password I was wondering if anyone could help me, I have...
2
16932
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jplane/certcent/phpweb/quiz/index.php on line 21 PHP CODE:
3
8688
by: varun aggarwal | last post by:
Hi i am doing a project in php that has to read the particular text from the file . I am still unable to get the source of error. what all it mentions is this message. "supplied argument is not a valid stream resource" This error on which it is giving me an error is marked in the code Here is the sample source code that i am working on. I even have tried changing the permissions for this. But that solution is also not worth.
1
2712
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127 My code is below. Any help would be much appreciated. ...
11
3605
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this when there is no result "empty table" how can i do a quick fix to say No Results... row 88: if ($myrow = mysql_fetch_array($result)) { do { if ($rowcolor == 1) {
7
2819
bobzillaforever
by: bobzillaforever | last post by:
I'm unable to get the file(s) in question to read with file_exists(), fread(), or probably any similar function. I've tried it with .txt, .flv, .pdf, .mov, .mp3, and .wmv. I've tried removing the following from my .htaccess file to no avail. <FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$"> Order allow,deny </FilesMatch> I've also tried...
0
9522
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...
1
9902
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
8770
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
7327
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
6603
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
5215
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
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
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
3
2738
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.