boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Another Image Upload Problem, but not related

 
Post new topic   Reply to topic    boardom Forum Index -> Installation issues
View previous topic :: View next topic  
Author Message
Da Brass



Joined: 25 Jul 2002
Posts: 3

PostPosted: Thu Jul 25, 2002 7:11 pm    Post subject: Another Image Upload Problem, but not related Reply with quote

I just installed b2 last night and I finally got everything running, except for the Image Uploading. Basically, there are 2 problems.

1) When I upload a file that is 2 big or not the right file type, it just refreshes back to the original upload page

2) When I do upload a correct file, it says nothing was wrong, but there was no image uploaded or moved and the info on the image is blank

--SNIP--

File uploaded !

Your file was uploaded successfully !

Here's the code to display it:




Image Details:
name:
size: 0 KB
type:

--SNIP--

Does anyone have any ideas?

Thanks!
Back to top
View user's profile Send private message
Fallen



Joined: 16 Mar 2002
Posts: 67
Location: Sao Paulo, Brasil

PostPosted: Thu Jul 25, 2002 11:14 pm    Post subject: Reply with quote

Have you changed all necessary parameters?

Code:


// ** Image upload **


# set this to 0 to disable file upload, or 1 to enable it
[b]$use_fileupload = 1;[/b]

# enter the real path of the directory where you'll upload the pictures
#   if you're unsure about what your real path is, please ask your host's support staff
[b]#   note that the  directory must be writable by the webserver (ChMod 766)[/b][b]#   note for windows-servers users: use forwardslashes instead of backslashes[/b]
[b]#$fileupload_realpath = '/home/your/site/b2/images';[/b]
[b]$fileupload_realpath = '/home/yourdomain/public_html/images';[/b]

# enter the URL of that directory (it's used to generate the links to the pictures)
[b]$fileupload_url = 'http://yourdomain.com/images';[/b]

# accepted file types, you can add to that list if you want
#   note: add a space before and after each file type
#   example: $fileupload_allowedtypes = ' jpg gif png ';
[b]$fileupload_allowedtypes = ' jpg gif png JPG GIF PNG';[/b]

# by default, most servers limit the size of uploads to 2048 KB
#   if you want to set it to a lower value, here it is (you cannot set a higher value)
[b]$fileupload_maxk = '96';[/b]

_________________
http://crube.net
Back to top
View user's profile Send private message Visit poster's website
Fallen



Joined: 16 Mar 2002
Posts: 67
Location: Sao Paulo, Brasil

PostPosted: Thu Jul 25, 2002 11:17 pm    Post subject: Reply with quote

// ** Image upload **


# set this to 0 to disable file upload, or 1 to enable it
$use_fileupload = 1;

# enter the real path of the directory where you'll upload the pictures
# if you're unsure about what your real path is, please ask your host's support staff
# note that the directory must be writable by the webserver (ChMod 766)# note for windows-servers users: use forwardslashes instead of backslashes
#$fileupload_realpath = '/home/your/site/b2/images';
$fileupload_realpath = '/home/yourdomain/public_html/images';

# enter the URL of that directory (it's used to generate the links to the pictures)
$fileupload_url = 'http://yourdomain.com/images';

# accepted file types, you can add to that list if you want
# note: add a space before and after each file type
# example: $fileupload_allowedtypes = ' jpg gif png ';
$fileupload_allowedtypes = ' jpg gif png JPG GIF PNG';

# by default, most servers limit the size of uploads to 2048 KB
# if you want to set it to a lower value, here it is (you cannot set a higher value)
$fileupload_maxk = '96';
_________________
http://crube.net
Back to top
View user's profile Send private message Visit poster's website
Da Brass



Joined: 25 Jul 2002
Posts: 3

PostPosted: Fri Jul 26, 2002 7:27 am    Post subject: Reply with quote

Yes, all values have been set properly, the images directory is even CHMOD'd 777, and it seems to upload, but not appear on the web site directory.

I've reset it with the default config file and re-did it all....still no luck. I'm a little at a loss as I have no clue what's going on.
Back to top
View user's profile Send private message
Da Brass



Joined: 25 Jul 2002
Posts: 3

PostPosted: Fri Jul 26, 2002 7:02 pm    Post subject: Reply with quote

Got it fixed.

I'm using PHP 4.2.1 and it's locked down pretty tight. Had to change some of the vars in the b2upload.php to make it compatible:

Original Code
Code:


  <?php  //Makes sure they choose a file
 
- if ($img1_name != "") {
 
!       $imgtype = explode(".",$img1_name);
        $imgtype = " ".$imgtype[count($imgtype)-1]." ";
 
        if (!ereg(strtolower($imgtype), strtolower($fileupload_allowedtypes))) {
                die("This file type $imgtype is not allowed by the admin of this blog.");
        }
!       $pathtofile = $fileupload_realpath."/".$img1_name;
!       move_uploaded_file("$img1" , "$pathtofile") //Path to your images directory, chmod the dir to 777
        or die("Couldn't Upload Your File to $pathtofile.");
 
  }
 
! $piece_of_code = "<img src="$fileupload_url/$img1_name" border="0" alt="" />";
 
  ?>
 
  <p><strong>File uploaded !</strong></p>
! <p>Your file <b><?php echo "$img1_name"; ?></b> was uploaded successfully !</p>
  <p>Here's the code to display it:</p>
  <p><form>
! <!--<textarea cols="25" rows="3" wrap="virtual"><?php echo "<img src="$fileupload_url/$img1_name" border="0" alt="" />"; ?></textarea>-->
  <input type="text" name="imgpath" value="<?php echo $piece_of_code; ?>" size="38" style="padding: 5px; margin: 2px;" /><br />
  <input type="button" name="close" value="Add the code to your post !" class="search" onClick="targetopener('<?php echo $piece_of_code; ?>')" style="margin: 2px;" />
  </form>
  </p>
  <p><strong>Image Details</strong>: <br />
  name:
! <?php echo "$img1_name"; ?>
  <br />
  size:
! <?php echo round($img1_size/1024,2); ?> KB
  <br />
  type:
! <?php echo "$img1_type"; ?>
  </p>
  <p align="right">
  <form>


Fixed code
Code:

 
  <?php  //Makes sure they choose a file
 
 
! if ($_FILES['img1']['name'] != "") {
!
!
!       $imgtype = explode(".",$_FILES['img1']['name']);
        $imgtype = " ".$imgtype[count($imgtype)-1]." ";
 
        if (!ereg(strtolower($imgtype), strtolower($fileupload_allowedtypes))) {
                die("This file type $imgtype is not allowed by the admin of this blog.");
        }
!       $pathtofile = $fileupload_realpath."/".$_FILES['img1']['name'];
!       move_uploaded_file($_FILES['img1']['tmp_name'] , "$pathtofile") //Path to your images directory, chmod the dir to 777
        or die("Couldn't Upload Your File to $pathtofile.");
 
  }
 
! $piece_of_code = "<img src="$fileupload_url/".$_FILES['img1']['name']."" border="0" alt="" />";
 
  ?>
 
  <p><strong>File uploaded !</strong></p>
! <p>Your file <b><?php echo $_FILES['img1']['name']; ?></b> was uploaded successfully !</p>
  <p>Here's the code to display it:</p>
  <p><form>
! <!--<textarea cols="25" rows="3" wrap="virtual"><?php echo "<img src="$fileupload_url/".$_FILES['img1']['name']."" border="0" alt="" />"; ?></textarea>-->
  <input type="text" name="imgpath" value="<?php echo $piece_of_code; ?>" size="38" style="padding: 5px; margin: 2px;" /><br />
  <input type="button" name="close" value="Add the code to your post !" class="search" onClick="targetopener('<?php echo $piece_of_code; ?>')" style="margin: 2px;" />
  </form>
  </p>
  <p><strong>Image Details</strong>: <br />
  name:
! <?php echo $_FILES['img1']['name']; ?>
  <br />
  size:
! <?php echo round($_FILES['img1']['size']/1024,2); ?> KB
  <br />
  type:
! <?php echo $_FILES['img1']['type']; ?>
  </p>
  <p align="right">
  <form>


Basically, just had to change the $img1 to the newer syntax of $_FILES['img1']...etc. Just look for the changes beginning with a "!".
Back to top
View user's profile Send private message
jadz



Joined: 05 Feb 2002
Posts: 13
Location: halifax, nova scotia, canada

PostPosted: Fri Aug 09, 2002 2:22 pm    Post subject: Reply with quote

Thanks for this fix. Works great now.
_________________
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Installation issues All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group