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

uploading file problems

I get these errors when uploading images via a web page:
(the page still uploads the images but reports these errors?)

Warning: fopen(D:\php\uploadtemp\php1FC7.tmp) [function.fopen]: failed
to create stream: No error in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 105

Warning: Wrong parameter count for filesize() in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109

Warning: fread(): supplied argument is not a valid stream resource in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109

Warning: Cannot modify header information - headers already sent by
(output started at D:\webspace\me.co.uk\wwwroot\test\Live.php:105) in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 138

This is the code at these errors:

105 = // Open file for binary reading ('rb')
$tempfile = fopen($uploadfile0,$uploadfile1,'rb');

109 = // Read the entire file into memory using PHP's
// filesize function to get the file size.
$filedata = fread($tempfile,filesize($uploadfile0,$uploadfile1 ));

138 = header('location: ' . $_SERVER['PHP_SELF']);

any one help?

I don't get this problem locally on apache 1.3.26 (win32) running php
4.2.2 BUT this happens when i use the same file on my live server
running php 4.3.0 on Windows NT

cheers Lion
Jul 17 '05 #1
7 3970
lion wrote:
I get these errors when uploading images via a web page:
(the page still uploads the images but reports these errors?)

Warning: fopen(D:\php\uploadtemp\php1FC7.tmp) [function.fopen]: failed
to create stream: No error in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 105

Warning: Wrong parameter count for filesize() in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109

Warning: fread(): supplied argument is not a valid stream resource in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109

Warning: Cannot modify header information - headers already sent by
(output started at D:\webspace\me.co.uk\wwwroot\test\Live.php:105) in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 138

This is the code at these errors:

105 = // Open file for binary reading ('rb')
$tempfile = fopen($uploadfile0,$uploadfile1,'rb');

109 = // Read the entire file into memory using PHP's
// filesize function to get the file size.
$filedata = fread($tempfile,filesize($uploadfile0,$uploadfile1 ));

138 = header('location: ' . $_SERVER['PHP_SELF']);

any one help?

I don't get this problem locally on apache 1.3.26 (win32) running php
4.2.2 BUT this happens when i use the same file on my live server
running php 4.3.0 on Windows NT

cheers Lion


I had a similar problem, got it solved by setting open_basedir in php.ini to
correct value.

You should go to www.php.net and read the manual on open_basedir for further
info as I don't have it here in my head ...

HTH,

/Andreas
--
Registeret Linux user #292411
Jul 17 '05 #2
ad*********@hotmail.com (lion) wrote in message news:<1f**************************@posting.google. com>...
I get these errors when uploading images via a web page:
(the page still uploads the images but reports these errors?)

Warning: fopen(D:\php\uploadtemp\php1FC7.tmp) [function.fopen]: failed
to create stream: No error in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 105

Warning: Wrong parameter count for filesize() in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109

Warning: fread(): supplied argument is not a valid stream resource in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109

Warning: Cannot modify header information - headers already sent by
(output started at D:\webspace\me.co.uk\wwwroot\test\Live.php:105) in
D:\webspace\me.co.uk\wwwroot\test\Live.php on line 138

This is the code at these errors:

105 = // Open file for binary reading ('rb')
$tempfile = fopen($uploadfile0,$uploadfile1,'rb');

109 = // Read the entire file into memory using PHP's
// filesize function to get the file size.
$filedata = fread($tempfile,filesize($uploadfile0,$uploadfile1 ));

138 = header('location: ' . $_SERVER['PHP_SELF']);

any one help?

I don't get this problem locally on apache 1.3.26 (win32) running php
4.2.2 BUT this happens when i use the same file on my live server
running php 4.3.0 on Windows NT

cheers Lion


Hi,

Please check the following:

LINE 105: fopen() function takes only a single file name argument and
the mode.
LINE 109: filesize() function takes only a single argument
LINE 138: With above two errors fixed this error will also get fixed.

Following is the correct syntax
fopen: resource fopen ( string filename, string mode [, int
use_include_path [, resource zcontext]] )

filesize: int filesize ( string filename )

-- Rahul
Jul 17 '05 #3
cheers guys!

one thing though regarding Rahul suggestion - I need to upload two
files (a big pic and its thumbnail) will I not be able to do this at
once if that is the case?

I'll give it a go

I guess I could put it in a loop...?

cheers
LINE 105: fopen() function takes only a single file name argument and
the mode.
LINE 109: filesize() function takes only a single argument
LINE 138: With above two errors fixed this error will also get fixed.

Following is the correct syntax
fopen: resource fopen ( string filename, string mode [, int
use_include_path [, resource zcontext]] )

filesize: int filesize ( string filename )

-- Rahul

Jul 17 '05 #4
right, I've tried just passing one file upload to the script but it
still does'nt work and reports the same errors, does any one know why
this works fine with php 4.2.2 on apache 1.3.26...? but not on my live
host which has php 4.3...

doesnt add up...

lion
Jul 17 '05 #5
> cheers guys!

one thing though regarding Rahul suggestion - I need to upload two
files (a big pic and its thumbnail) will I not be able to do this at
once if that is the case?

I'll give it a go

I guess I could put it in a loop...?

cheers


Hi again,

Multiple files can be uploaded by running a loop and processing file
in iteration.

Following is the an example of caode that can handle multiple files
upload:

// Start of code
<?
if(!empty($_FILES))
{
$uploaddir = "../NewsLetterImages/";
$errorMessage =
array(
1=>"File exceeds the 2 MB limit" ,
2=>"File exceeds the 2 MB limit",
3=>"Only partially uploaded.",
);

foreach($_FILES['htmlImageFiles']['name'] as $vk=>$vv)
{
if(!empty($vv))
{
if(!file_exists($uploaddir . $vv) &&
$_FILES['htmlImageFiles']['error'][$vk] == 0)
move_uploaded_file($_FILES['htmlImageFiles']['tmp_name'][$vk],
$uploaddir . $vv);
else
{
$message = $vv;
if($_FILES['htmlImageFiles']['error'][$vk] != 0)
$message .= " (".$errorMessage[$_FILES['htmlImageFiles']['error'][$vk]].")
";
else
$message .= " (File already exists) ";
$errorFiles[] = $message;
}
}
}
if(!empty($errorFiles))
{
// Error Uploading files
$_HEADER_="Error Uploading Files";
$_MESSAGE_="Sorry! Unable to uplaod following files:-<p>
".implode('<br>',$errorFiles);
$_MESSAGE_ .= "<p><a href='uploadForm.html'>Go back to try
again</a><p>Please note you can not upload duplicate files or files of
size greater than 2 MB.";
include_once "errorPage.php";
exit;
}
// Success
header("Location: succesPage.php");
exit;
}
?>
// End of code

In my HTML form I used this code

<!-- START HTML CODE -->

<table>
<tr>
<td align="center"><h3>Upload Newsletter Images</h3></td>
</tr>
<tr>
<td class="normal_style">
<b>Image File 1</b>
<input type="file" name="htmlImageFiles[]"><p>
</td>
</tr>
<tr>
<td class="normal_style">
<b>Image File 2</b>
<input type="file" name="htmlImageFiles[]"><p>
</td>
</tr>
<tr>
<td class="normal_style">
<b>Image File 3</b>
<input type="file" name="htmlImageFiles[]"><p>
</td>
</tr>
<tr>
<td class="normal_style">
<b>Image File 4</b>
<input type="file" name="htmlImageFiles[]"><p>
</td>
</tr>
</table>

<!-- END HTML CODE -->
I guess this will help.

-- Rahul
Jul 17 '05 #6
ad*********@hotmail.com (lion) wrote in message news:<1f**************************@posting.google. com>...
right, I've tried just passing one file upload to the script but it
still does'nt work and reports the same errors, does any one know why
this works fine with php 4.2.2 on apache 1.3.26...? but not on my live
host which has php 4.3...

doesnt add up...

lion


are you getting the same errors?

please write your modified code and errors you are getting.

-- Rahul
Jul 17 '05 #7
That was just the ticket - works perfect!

thankyou very much Rahul

Lion
Jul 17 '05 #8

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

Similar topics

5
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of...
3
by: Mike | last post by:
Hi i have a problem in asp.ne i am uploading file to the server using htmlinput controls and every thing is o but i try to upload larger file to the server like more than 4 mb and about 10mb i got...
1
by: Thorsten Wienbarg | last post by:
Hi there, after doing some reading on this subject, I found lots of information on how to actually avoid not uploading a file. They don't tell me how to exclude the contents of a file though. ...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
3
by: OriginalBrownster | last post by:
I am currently uploading a file from a users computer to the file system on my server using python, just reading the file and writing the binaries. total_data=' ' while True: data =...
7
by: jambroo | last post by:
Hello, We are currently having issues uploading files using PHP. It seems files below 8MB are uploaded fine, however files above 8.2MB cause the page to timeout or show a 'Cannot find server or...
2
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
jodleren escribió: I haven't found the PHP manual page where such feature is documented but a few tests have shown that this behaviour changes depending on the charset parameter of the...
10
by: =?Utf-8?B?RGFu?= | last post by:
I'm using a pure ASP upload script to handle file uploading. We run IIS6 and I'm aware of the AspMaxRequestEntityAllowed variable in the metabase. I upped this to allow the file size maximum and it...
1
by: Faisal Shafiq | last post by:
I want to upload a file direct to the Silverlight Streaming Service from a Web Client such as silverlight application. As per our product requirement we want to upload a .WMV file directly from...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.