PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old May 20th, 2002, 09:34 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Problems: fle uploading vs temp path.

Hi,originally this script
runs well on my local machine Apache+php+Mysql. But
once I uploaded it to my free
website,it
became useless.


When I executed the following script,
I
got the following errors:

Warning: fopen("", "r") - No such
file
or directory in

C:webserverwebservermanagergigiclubuploadtest.php on
lin
e 7

Warning: fread(): supplied argument
is
not a valid File-Handle resource in

C:webserverwebservermanagergigiclubuploadtest.php on
lin
e 7

My script


---------------------------uploadtest.php-------------------

---------------



<?php require('config.php'); ?>
<?
//uploadtest.php
global $PHP_SELF,$yourname,$image;

if($submit){
$img = addslashes(fread(fopen($image,
"r"), filesize($image)));
$query="insert into mytable
values('$yourname','$img')";

$result=mysql_db_query("mydatabase",$query);
if($result)
print("Thank you $yourname,your image
file is successfully uploaded");
else
print("Couldn't upload your image
file.");
}

else {
print("
<form enctype=multipart/form-data
action=$PHP_SELF method=post>
<table><tr><td>Your name<input
name=yourname></td></tr>
<tr><td>Your image file<input
type=file
name=image><input type=submit
name=submit

value=submit></td></tr></table></form>");
}
?>

My config.php contains all the info
needed connecting to MySQL
database(host,username,password..)

And my sql script is as followed:

create table mytable(yourname
varchar(40),image blob);


My problem is that when the fopen /
fread command
looks for the tmp folder - it can`t
find
it. I have even tried adding
$image =
str_replace("\\","\",$image); (but still not working)
I think there should be some problems
with this line:
$img = addslashes(fread(fopen($image,
"r"), filesize($image)));


Please help. Thank you.
David Foo
janhouse00@hotpop.com

Reply With Quote
  #2  
Old May 20th, 2002, 10:07 PM
sLYsHARk sLYsHARk is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Istanbul // TURKEY
Posts: 3 sLYsHARk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to sLYsHARk
RE: Problems: fle uploading vs temp path.

Quote:
Warning: fopen("", "r") - No such file or directory


as you see the variable $image can not be found and used on your "fopen" function to handle the file. If fopen function could get the variable, it should got some errors like follows:

Quote:
Warning: fopen("file.ext", "r") - No such file or directory

Reply With Quote
  #3  
Old May 21st, 2002, 07:01 AM
michael michael is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 41 michael User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Problems: fle uploading vs temp path.

is the folder you are trying to grab info out of chmod'd correctly?

That is a typical error that i received a couple of times, when it was not 755 or 777.

It all depends on what server you are running on to, so normally the (r) or (w) on some systems are basically useless...to combat it, you can try this command
chmod("thisfile.txt",777)

of course, FTPing to the file, and using the CHMOD mode works much better.

(something like that anyways

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Problems: fle uploading vs temp path.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway