Current location: Hot Scripts Forums » Programming Languages » PHP » HTTP wrapper does not support writeable connections


HTTP wrapper does not support writeable connections

Reply
  #1 (permalink)  
Old 03-07-04, 03:53 PM
b3groove b3groove is offline
New Member
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question HTTP wrapper does not support writeable connections

Hi, could someone help me figure out a solution to this probelm.
I'm using zClassifieds, and am having trouble with the img file upload part.

The 2 lines of code which generate the error are:

copy( $newphoto[ $i ], "{$IMAGE_DIR}/{$photoid}.jpg" );
makeThumb( $newphoto[ $i ], "{$IMAGE_DIR}/thumb/{$photoid}.jpg" );

makeThumb is an img resizer script in the common.php library.

The errors I get are:

Warning: copy(http://b3groove.org/ads/images/6.jpg): failed to open stream: HTTP wrapper does not support writeable connections. in /home/b3groove/public_html/ads/list.php on line 51

Warning: imagejpeg(): Unable to open 'http://b3groove.org/ads/images/thumb/6.jpg' for writing in /home/b3groove/public_html/ads/common.php on line 205

I found some info on this on another site, and it says that this is because the PHP.INI setting safe_mode is off. I am unable to change this setting using httpd.conf because my host does not allow it.

I found an image upload script which works on my site with safe_mode off, but I do not know how to modify the existing script to use the method of this new script. Here is the code of this new script:

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "upload failed!<br>\n"; exit; } else { echo "upload sucessful<br>\n"; }

Can anyone help out?
Reply With Quote
  #2 (permalink)  
Old 03-07-04, 05:29 PM
b3groove b3groove is offline
New Member
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Well, I found another upload script which uses the same method as mine, and works on my site. I replaced the upload part of my script with this new upload script, and I still get the same error message. There must be something wrong with the rest of the original script. Can anyone help, please?

for( $i = 0; $i < count( $photo ); $i++ )
{
if( $photo[ $i ] != "" && $photo[ $i ] != "none" )
{
if( $photo_size[ $i ] > 500000 ) error( "Invalid image size!" );
if( $photo_type[ $i ] == "image/pjpeg" || $photo_type[ $i ] == "image/jpeg" )
$newphoto[] = $photo[ $i ];
else
error( "Invalid image type, JPEG only!" );
}
}
$time = time();
$exptime = $time + $days * 3600 * 24;
mysql_query( "INSERT INTO zads ( cat_id, user_id, subject, descript, url, add_date, exp_date ) VALUES ( $cat, $user_id, '$subject', '$descript', '$url', $time, $exptime )" ) or error( mysql_error() );
$newid = mysql_insert_id();
for( $i = 0; $i < count( $newphoto ); $i++ )
{
$img = ImageCreateFromJPEG( $newphoto[ $i ] );
$imgW = ImageSX( $img );
$imgH = ImageSY( $img );
mysql_query( "INSERT INTO zphoto ( ad_id,phX,phY ) VALUES ( $newid,$imgW,$imgH )" ) or error( mysql_error() );
$photoid = mysql_insert_id();
copy( $newphoto[ $i ], "{$IMAGE_DIR}/{$photoid}.jpg" );
makeThumb( $newphoto[ $i ], "{$IMAGE_DIR}/thumb/{$photoid}.jpg" );
unlink( $newphoto[ $i ] );
}
Reply With Quote
  #3 (permalink)  
Old 03-09-04, 05:00 PM
Kirre Kirre is offline
New Member
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

I had the same error, for this script from zclassifids.

My solution was in the, vars.php ,file.

Original this peace of code:
$IMAGE_DIR = "./image";

I had replaced the "path" for image upload with the "URL" witch is wrong,
there should be placed
the path to the image upload directory.

Hope that helps.


Quote:
Originally Posted by b3groove
Hi, could someone help me figure out a solution to this probelm.
I'm using zClassifieds, and am having trouble with the img file upload part.

The 2 lines of code which generate the error are:

copy( $newphoto[ $i ], "{$IMAGE_DIR}/{$photoid}.jpg" );
makeThumb( $newphoto[ $i ], "{$IMAGE_DIR}/thumb/{$photoid}.jpg" );

makeThumb is an img resizer script in the common.php library.

The errors I get are:

Warning: copy(http://b3groove.org/ads/images/6.jpg): failed to open stream: HTTP wrapper does not support writeable connections. in /home/b3groove/public_html/ads/list.php on line 51

Warning: imagejpeg(): Unable to open 'http://b3groove.org/ads/images/thumb/6.jpg' for writing in /home/b3groove/public_html/ads/common.php on line 205

I found some info on this on another site, and it says that this is because the PHP.INI setting safe_mode is off. I am unable to change this setting using httpd.conf because my host does not allow it.

I found an image upload script which works on my site with safe_mode off, but I do not know how to modify the existing script to use the method of this new script. Here is the code of this new script:

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "upload failed!<br>\n"; exit; } else { echo "upload sucessful<br>\n"; }

Can anyone help out?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 09:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.