You are here: Re: Chmod « PHP Programming Language « IT news, forums, messages
Re: Chmod

Posted by frizzle on 11/19/05 11:45

Jerry Stuckle wrote:
> frizzle wrote:
> > Jerry Stuckle wrote:
> >
> >>frizzle wrote:
> >>
> >>>Jerry Stuckle wrote:
> >>>
> >>>
> >>>>frizzle wrote:
> >>>>
> >>>>
> >>>>>Jerry Stuckle wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>>frizzle wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>>I asked my webhost, but they told me uploading
> >>>>>>>a folder and having it running uploads etc. is not
> >>>>>>>possible on Linux by default. Folders should be
> >>>>>>>chmod 777 or chmod 755.
> >>>>>>>
> >>>>>>>Frizzle.
> >>>>>>>
> >>>>>>
> >>>>>>Yes and no. It depends on how they have their folders configured.
> >>>>>>
> >>>>>>However, obviously they have it configured so you can't do it. But you should
> >>>>>>still be able to create the folder in PHP from a web page (so it's running as
> >>>>>>the Apache user) and upload to it. The folder should then have the Apache user
> >>>>>>as the owner.
> >>>>>>
> >>>>>>--
> >>>>>>==================
> >>>>>>Remove the "x" from my email address
> >>>>>>Jerry Stuckle
> >>>>>>JDS Computer Training Corp.
> >>>>>>jstucklex@attglobal.net
> >>>>>>==================
> >>>>>
> >>>>>
> >>>>>AFAIK the script below should be able to create dirs then
> >>>>>but i get the following error:
> >>>>>
> >>>>>Warning: mkdir(testdir): Permission denied in
> >>>>>/usr/local/psa/home/vhosts/host.com/httpdocs/test/mkdir.php on line 5
> >>>>>
> >>>>>Warning: Cannot modify header information - headers already sent by
> >>>>>(output started at
> >>>>>/usr/local/psa/home/vhosts/host.com/httpdocs/test/mkdir.php:5) in
> >>>>>/usr/local/psa/home/vhosts/host.com/httpdocs/test/mkdir.php on line 6
> >>>>>
> >>>>>Frizzle.
> >>>>>
> >>>>>+++++++++++++++++++++++++++++++++++++++++++++++++++
> >>>>>
> >>>>><?php
> >>>>>
> >>>>> if(isset( $_POST['dir'] ))
> >>>>> {
> >>>>> mkdir( $_POST['dir'], 0755 );
> >>>>> header('Location: '.$PHP_SELF);
> >>>>> };
> >>>>>
> >>>>>
> >>>>>?><form action="<?php echo $PHP_SELF; ?>" method="post"
> >>>>>name="mkdirtest" target="_top" id="mkdirtest">
> >>>>> <label for="dir">dir</label>
> >>>>> <input type="text" name="dir" id="dir"<?php echo isset( $_POST['dir']
> >>>>>) ? ' value="'.$_POST['dir'].'"' : '' ?>>
> >>>>> <label for="Submit"></label>
> >>>>> <input type="submit" name="Submit" value="mkdir!" id="Submit">
> >>>>></form><?php
> >>>>>
> >>>>>$handle = opendir('.');
> >>>>>
> >>>>>while (false !== ($file = readdir($handle))) {
> >>>>> if ($file != "." && $file != ".." ) {
> >>>>> echo $file.'<br>';
> >>>>> };
> >>>>>};
> >>>>>
> >>>>>closedir( $handle );
> >>>>>
> >>>>>?>
> >>>>>
> >>>>What happens if you leave off the 0755? That may be restricted in your
> >>>>location. Just try it with the default.
> >>>>
> >>>>If it still doesn't work, looks like it's time to find another host. This one
> >>>>has too many restrictions.
> >>>>
> >>>>
> >>>>--
> >>>>==================
> >>>>Remove the "x" from my email address
> >>>>Jerry Stuckle
> >>>>JDS Computer Training Corp.
> >>>>jstucklex@attglobal.net
> >>>>==================
> >>>
> >>>
> >>>Hmm, that's really crap. 755 does nothing more, and changing hosts
> >>>isn't really an option. ... :(
> >>>
> >>>Frizzle.
> >>>
> >>
> >>But unfortunately, it looks like your host has too many things locked down for
> >>you to be able to upload files through the website.
> >>
> >>I can partially understand their reasoning in a shared environment. But at the
> >>same time, other hosting companies can do it. So why can't they?
> >>
> >>
> >>--
> >>==================
> >>Remove the "x" from my email address
> >>Jerry Stuckle
> >>JDS Computer Training Corp.
> >>jstucklex@attglobal.net
> >>==================
> >
> >
> > I guess you're right, but i really really don't want to change hosts. I
> > have multiple
> > sites hosted there, knowing their service etc. is great. (And still is)
> > This is the
> > first kind of problem i've come across.
> >
> > I mailed them with my problem, and saying i don't want to swich, and if
> > they can
> > come up with another solution. If not, then i'll see ...
> >
> > I looked into another old site on one of their servers wich was meant
> > as an online
> > diary with a photo gallery. I created an upload-module for photos.
> > These were
> > automatically resized by PHP. Looking through Plesk's file manager, i
> > can see the
> > folder the pics end up in is chmodded rwx r-x r-x (755), pics are rw-
> > r-- r-- (644)
> >
> > Pics and folder have the same owner, and belong to the same group. Pics
> > are as
> > i said PHP created, the folder was done in dreamweaver, but probably
> > chmodded
> > manually. I wonder if this is possible for other files then images,
> > because they
> > don't have to be resampled, so aren't actually created by PHP.
> >
> > I hope you get what i'm saying.
> >
> > Frizzle.
> >
>
> Yes, I see what you're saying. However, I don't think it should make a
> difference like you think. Whether it's an image that's been sampled or a file
> that's been uploaded, the Apache userid is doing the work.
>
> The difference I can see is that the move_uploaded_files probably calls a system
> function to actually move the files (don't know - I haven't looked). Obviously
> the pix site doesn't do this when it resizes the pix; don't know what it does
> before that, though.
>
> the other possibility is they have the other server configured differently -
> either PHP or the OS (or both). phpinfo() could tell you if there are PHP
> differences.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================

PHP & OS are similar.
My upload function is below.
Hope it can get me/you any further ...
(again, really thanks for all the help!!)

Frizzle.

******* C O D E - A L E R T ! ! ! ************************
<?php

function ResizeUpload( $this_uploaded_image )
{

global $album_id; // id of album where pic should end up in
global $conn_id;

$maxSize = 500;

$tmp_image = imagecreatefromjpeg($this_uploaded_image);
$width = imagesx($tmp_image);
$height = imagesy($tmp_image);

$maxSide = ( $width > $height ) ? $width : $height;

if ($maxSide > $maxSize)
{
$ratio = $maxSize / $maxSide;
$new_width = round( $width * $ratio, 0 );
$new_height = round( $height * $ratio, 0 );
}
else
{
$new_width = $width;
$new_height = $height;
};

$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresized($new_image, $tmp_image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);

//Grab new image
ob_start();
imagejpeg($new_image, '', 90);
$image_buffer = ob_get_contents();
ob_end_clean();
imagedestroy($new_image);

//Create temporary file and write to it
$fp = tmpfile();
fwrite($fp, $image_buffer);
rewind($fp);

$created = date("YmdHis");

$addpic = mysql_query("INSERT INTO photos (album_id) VALUES
($album_id)") or die(mysql_error());
$this_image_name= substr('0000000000'.mysql_insert_id(), -10, 10);

//Upload new image
if(ftp_fput($conn_id,'/httpdocs/img/photos/'.$this_image_name.'.jpg',
$fp, FTP_BINARY))
{

$_SESSION['UploadedPics'] += 1;

}
else
{

$error_reporting += 1;

};

fclose($fp);
};


$conn_id = ftp_connect('ftp.host.com');
ftp_login( $conn_id, 'loginname', 'pass')or die('Error :( ');

ResizeUpload($_FILES['image']['tmp_name'] );

ftp_close($conn_id);

?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация