CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 NOW : Full Image uploading System.(Insert - Update - Delete)+thumbnail...And more

Print topic Send  topic

Author Message
beshoo

Posts: 68
Posted: 07/18/2004, 4:01 PM

Full uploading System.

System specification:
You can :
1- Upload images with CCS limitation ( Image size and extension ) .
2- System will make a small thumbnail and will type you web site name on the original image
3- You can adjust you image quality, Fixed size, for original and thumbnail file.
4- The name of the image will stored in the database
5- You can Insert - Update - Delete.

To do:
1- Un back the ccsu.rar by using winrar , you can download it from http://www.download.com.
2- Chmod the following folder to 777 permeation [thump | upload]

This example is free to use.

Thank you and best regards

Beshoo

Download section:
http://www.beshoo.com/ccsu.rar
_________________
beshoo Love PHP and CC 4.2
View profile  Send private message
beshoo

Posts: 68
Posted: 07/18/2004, 4:09 PM

Please run this on your Mysql Command line or on PHPmyadmin

#database name : basell
#Mysql Database
#----------------------
CREATE TABLE upload (
id int(10) unsigned NOT NULL auto_increment,
b_image varchar(50) default '0',
KEY id (id)
) TYPE=MyISAM;


_________________
beshoo Love PHP and CC 4.2
View profile  Send private message
wkempees


Posts: 1679
Posted: 07/18/2004, 6:15 PM

Beshoo:
Nice effort, please state the searchterm for www.download.com.
or provide the exact link to the download.
I am very interested.
Have a wish for an extension, insert, update, delete of the image as a blob (binary large object) in the database itself.

Greetings,
Walter8-)
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 07/18/2004, 6:17 PM

oops.
found the download link in the bottom of your message.
Sorry 03.15 GMT +1

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
beshoo

Posts: 68
Posted: 07/19/2004, 8:18 AM

No problem ..
I hope that you like my script and if you have any error please report it .
_________________
beshoo Love PHP and CC 4.2
View profile  Send private message
beshoo

Posts: 68
Posted: 07/19/2004, 8:21 AM

for your comment
Quote :
a blob (binary large object) in the database itself.

i think when we save the images in files that well be good than saving it into databse
but we can save it by convert the image by Base64

thank you and best regrads.
_________________
beshoo Love PHP and CC 4.2
View profile  Send private message
anany
Posted: 10/12/2004, 11:52 PM

Thanks beshoo!!!

Great functions!!!
under

Posts: 1
Posted: 01/12/2005, 2:11 AM

I have changed all instances:
'imagecreate' => 'imagecreateTRUECOLOR'
'imagecopyresized' => 'imagecopyRESAMPLED'
for better quality.
All working very good. Thanks beshoo.
View profile  Send private message
Jerry
Posted: 01/14/2005, 2:49 PM

Hi

I get the following error

Warning: imagecreatefromjpeg(http://www.biam.co.uk/test/upload/200501142251530.NGRMJA2096.jpg): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /home/biamco/public_html/test/images_events.php on line 59

Warning: imagesy(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 60

Warning: imagesx(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 61

Warning: imagecreate(): Invalid image dimensions in /home/biamco/public_html/test/images_events.php on line 65

Warning: imagecopyresized(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 66

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 68

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 69

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 70

Warning: imagecreatefromjpeg(http://www.biam.co.uk/test/upload200501142251530.NGRMJA2096.jpg): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /home/biamco/public_html/test/images_events.php on line 28

Warning: imagesx(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 30

Warning: imagesy(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 30

Warning: imagecreate(): Invalid image dimensions in /home/biamco/public_html/test/images_events.php on line 30

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 32

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 34

Warning: imagesx(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 36

Warning: imagesy(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 38

Warning: imagestring(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 38

Warning: imagesx(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 40

Warning: imagesy(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 40

Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 40

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 43

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/biamco/public_html/test/images_events.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /home/biamco/public_html/test/images_events.php:59) in /home/biamco/public_html/test/images.php on line 658

Regards

Jerry
Jerry
Posted: 01/16/2005, 5:51 AM

Hi

To solve the problem above you have to use the absolute address

/home/username/public_html/test/upload/

I have now modified the code to adjust the image by pixels size rather than % percentage

http://www.javhostings.co.uk/files/ccsu.zip

Regards

Jerry
Viktor
Posted: 01/20/2005, 6:10 AM

And I get

Fatal error: Call to undefined function: imagecreatefromjpeg()

Any suggestions?

Thanks!
feha2
Posted: 01/20/2005, 8:14 AM

Quote Viktor:
And I get

Fatal error: Call to undefined function: imagecreatefromjpeg()

Any suggestions?

Thanks!

You must have enalbed GD library ...

karen

Posts: 99
Posted: 02/04/2005, 3:59 AM

I have successfully implemented this example and I just want to say thanks to beshoo, Jerry and all the rest who have contributed!

At the same time, can anyone explain why the thumbnail deletion process in the Form - After Execute Update event doesn't also have to be in the Form - After Execute Delete event ? I just want to understand it better.

Thanks again!
View profile  Send private message
RobertC
Posted: 02/06/2005, 7:00 AM

Tnx for your script!!

du u have any messengers ?? like MSN, Yahoo, ICQ, if yes shoot me an reply pls!!

many tnx for teh script again
.....................................................


Quote beshoo:
Full uploading System.

System specification:
You can :
1- Upload images with CCS limitation ( Image size and extension ) .
2- System will make a small thumbnail and will type you web site name on the original image
3- You can adjust you image quality, Fixed size, for original and thumbnail file.
4- The name of the image will stored in the database
5- You can Insert - Update - Delete.

To do:
1- Un back the ccsu.rar by using winrar , you can download it from http://www.download.com.
2- Chmod the following folder to 777 permeation [thump | upload]

This example is free to use.

Thank you and best regards

Beshoo

Download section:
http://www.beshoo.com/ccsu.rar
PeterJ


Posts: 90
Posted: 10/08/2005, 10:58 AM

I mistakenly posted this to the main forum earlier. It should have been here (sorry to donb for answering the question in the wrong forum)

Is there a workaround for this problem?

Warning: copy(): open_basedir restriction in effect. File(/tmp/phpehdB3A) is not within the allowed path(s): (/home/mysite/public_html) in /home/mysite/public_html/upl/Classes.php on line 1168

I get this when I try to run this upload script.

Thanks
View profile  Send private message
peterr


Posts: 5971
Posted: 10/08/2005, 11:31 AM

Based on http://www.google.com/search?hl=en&q=%22open_basedir+re...on+in+effect%22 I am suspecting that possibly your Web hosting company disabled the upload functionality. You can use Google search to find more information, or contact your Web hosting company for help.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
PeterJ


Posts: 90
Posted: 10/08/2005, 12:12 PM

Hi peterr

Thank you for responding. The open_basedir is set to "no value" I think this is ok? Or am I wrong. the article you point to suggest it is ok unless I have read it incorrectly?

PeterJ
View profile  Send private message
peterr


Posts: 5971
Posted: 10/08/2005, 12:20 PM

I don't know anything about this problem, just pointed a way to research it. I'm also not sure which article you are referring to because I didn't point to any specific one, but many of those articles talk about safe mode. Therefore I suspect that your hosting company may need to help you with this and tell if you if they use safe mode, what are their hosting restrictions and requirements, which folders to use for upload, etc.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
PeterJ


Posts: 90
Posted: 10/09/2005, 5:54 AM

Hi

Sorry for being dumb. The value for open_basedir is "no value" and I have assumed this is ok to my knowledge.

I appears that this is a pathing problem as much as anything. I have set the folders to '777' but still the project is telling me I have insufficient file permissions. My ISP tells me I cannot access any file outside the home directory (logically). I have tried /home/mysite/public_html/the_project as a path but still get this error.

Can anyone assist me with suggestions to solve the path problem please?

Thanks
View profile  Send private message
PeterJ


Posts: 90
Posted: 10/09/2005, 6:38 AM

Ok, I have this running locally and it looks as though the open_basedir is an issue.

Can anyone tell me where the temporary files are stored please? there is a folder in the design structure called "temp" but when I try to run this on the the remote server I get the open_basedir error message suggesting that this script is trying to store the temp files in another location other than the provided temp folder.
View profile  Send private message
Damian Hupfeld
Posted: 10/09/2005, 10:22 PM

On a hosted server account you will prolly find that you do not need to add
the /home/mysite/ directories -

The site is shared amongst many users/accounts and will automatically log
your ftp user into the root directory of YOUR account not the servers
FTPROOT or WWWROOT.

You login using yourname/yourpass and you would see ftp://ftp.yourname.com/
whilst I would login to the same host but using myname/mypass and
ftp://ftp.myname.com/

So in your Project Settings you would have
server: www.yourname.com
path: public_html

In your file upload settings you would use
temp folder: temp
file folder: photos

or whatever works for you. The folders must exist and you need 777
permissions.

regards
Damian Hupfeld
http://www.nexthost.com.au/services.php




"PeterJ" <PeterJ@forum.codecharge> wrote in message
news:543491306d204b@news.codecharge.com...
> Hi
>
> Sorry for being dumb. The value for open_basedir is "no value" and I have
> assumed this is ok to my knowledge.
>
> I appears that this is a pathing problem as much as anything. I have set
> the
> folders to '777' but still the project is telling me I have insufficient
> file
> permissions. My ISP tells me I cannot access any file outside the home
> directory (logically). I have tried /home/mysite/public_html/the_project
> as a
> path but still get this error.
>
> Can anyone assist me with suggestions to solve the path problem please?
>
> Thanks
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

PeterJ


Posts: 90
Posted: 10/10/2005, 12:33 AM

Thanks Damian

I have the paths worked out but the error persists. It appears that on uploading the file is being placed into an alternative temporary folder hence this part of the error message: File(/tmp/phpehdB3A) is not within the allowed path(s): This path does not exist within any of the files. All folders set to 777 by the way.

Thanks for your comments
View profile  Send private message
Damian Hupfeld
Posted: 10/10/2005, 5:04 AM

I usually define my own temp directory - called t1, temp or tmp etc... then
instead of using %temp% I use the actual directory name in the upload
module.

Damian



"PeterJ" <PeterJ@forum.codecharge> wrote in message
news:5434a19401878d@news.codecharge.com...
> Thanks Damian
>
> I have the paths worked out but the error persists. It appears that on
> uploading the file is being placed into an alternative temporary folder
> hence
> this part of the error message: File(/tmp/phpehdB3A) is not within the
> allowed path(s):
This path does not exist within any of the files. All
> folders set to 777 by the way.
>
> Thanks for your comments
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

peterr


Posts: 5971
Posted: 10/10/2005, 12:42 PM

PeterJ,
I previously looked at that application above and I see that the File Upload is already configured to use the "upload" and "upload/temp" folders. Thus I also don't understand why "/tmp/phpehdB3A" is used, and was suspecting that it's something related to server configuration and the hosting company may need to help you with this.

Since you still have the problem, I also don't understand it and cannot help but can recommend that you :
1. Verify that the "upload" and "upload/temp" folders actually exist.

2. Try changing the program's configuration to use full path instead of the relative one, like "/home/mysite/public_html/upl/upload" and "/home/mysite/public_html/upl/upload/temp".

3. Review php.ini for any related settings.
For example based on http://us3.php.net/features.file-upload :
Quote :
Files will, by default be stored in the server's default temporary directory, unless another location has been given with the upload_tmp_dir directive in php.ini.

4. Find and install any PHP upload example from anywhere on the Internet, then check if that one works. If you experience the same problem then you may need to talk to your Web hosting company.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
PeterJ


Posts: 90
Posted: 10/12/2005, 12:15 AM

Hi peterr

I too couldn't work out the problem having tried several paths etc. Anyway, I contacted the Support Team. Clearly there was an issue because they recommended upgrading to the latest version, which I use anyway, but more importantly they sent me a new Classes.ccl file to replace the existing. This resolved the issue and the script works fine.

regards PeterJ
View profile  Send private message
beshoo

Posts: 68
Posted: 10/15/2005, 4:28 PM



Dear all Codecharge members

Thank you for using my script , rely that’s big honor to me :)

some ppl have a problems with paths , I thing the problem is pretty easy to solve, and thanks for Mr. Petter for his help .

My MSN
beshoo@hotmail.com

any help I will be glad to do it.


beshoo

_________________
beshoo Love PHP and CC 4.2
View profile  Send private message
jayef
Posted: 10/19/2005, 5:02 AM

great, thanks alot
travel-net-bv
Posted: 10/21/2005, 2:34 PM

:-)
Works very well. I've changed all full paths to relative, so it is easier to port these codes to other sites and configurations.
//Custom Code @14-FF3FD3DA  
// -------------------------  
    global $NewRecord1;  
  
  
function typeonimg($imagefilename,$websitename,$imagesavefile)  
{  
  
$im = imageCreateFromJPEG($imagefilename);  
    $im2= imagecreate (imagesx($im),imagesy($im)+20);  
    $background_color  = imagecolorallocate($im2, 255, 255, 255);  
    $text_color = ImageColorAllocate ($im2, 255, 255, 0);  
    $start_text = (imagesx($im2)/2)-9*(strlen($websitename)/2);  
    ImageString ($im2, 5, $start_text, (imageSY($im)+3), $websitename, $text_color);  
    imageCopyMerge($im2, $im,0,0,0,0,(imageSX($im)),(imageSY($im)),100);  
    @unlink($imagefilename);  
    imagejpeg ($im2,$imagesavefile,100);  
    imagedestroy($im2);  
}  
  
function thumbbeshoo($entry,$src,$path,$prefix,$size,$qual){  
//JPG  
if(eregi(".+\.jpe?g$",$entry)){  
if(!file_exists("$path/$prefix".$entry)){  
  
$max_width    = 220;  
$max_height   = 220;  
$size=GetImageSize("images/upload/$entry");  
$width_ratio  = ($size[0] / $max_width);  
$height_ratio = ($size[1] / $max_height);  
   
if($width_ratio >=$height_ratio)   
{  
   $ratio = $width_ratio;  
}  
else  
{  
   $ratio = $height_ratio;  
}  
   
$new_width    = ($size[0]  / $ratio);  
$new_height   = ($size[1]  / $ratio);  
$src=ImageCreateFromJPEG("$src/$entry");  
$img = ImageCreateTrueColor($new_width,$new_height);  
ImageCopyRESAMPLED($img,$src,0,0,0,0,($new_width-1),($new_height-1),$size[0],$size[1]);  
$new_src=($path.$prefix.$entry);  
ImageJPEG($img,$new_src,$qual);  
ImageDestroy($img);  
ImageDestroy($src);  
}//End check for exising thumbnail  
}//End jpg check  
  
//GIF  
elseif(eregi(".+\.gif$",$entry)){  
if(!file_exists("$path/$prefix".$entry)){  
$max_width    = 220;  
$max_height   = 220;  
$size=GetImageSize("images/upload/$entry");  
$width_ratio  = ($size[0] / $max_width);  
$height_ratio = ($size[1] / $max_height);  
   
if($width_ratio >=$height_ratio)   
{  
   $ratio = $width_ratio;  
}  
else  
{  
   $ratio = $height_ratio;  
}  
   
$new_width    = ($size[0]  / $ratio);  
$new_height   = ($size[1]  / $ratio);  
$src=ImageCreateFromGIF("$src/$entry");  
$img = ImageCreateTrueColor($new_width,$new_height);  
ImageCopyRESAMPLED($img,$src,0,0,0,0,($new_width-1),($new_height-1),$size[0],$size[1]);  
$new_src=($path.$prefix.$entry);  
ImageGIF($img,$new_src,75);  
ImageDestroy($img);  
ImageDestroy($src);  
}//End check for exising thumbnail  
}//end GIF check  
//PNG  
elseif(eregi(".+\.png$",$entry)){  
if(!file_exists("$path/$prefix".$entry)){  
$max_width    = 220;  
$max_height   = 220;  
$size=GetImageSize("images/upload/$entry");  
$width_ratio  = ($size[0] / $max_width);  
$height_ratio = ($size[1] / $max_height);  
   
if($width_ratio >=$height_ratio)   
{  
   $ratio = $width_ratio;  
}  
else  
{  
   $ratio = $height_ratio;  
}  
   
$new_width    = ($size[0]  / $ratio);  
$new_height   = ($size[1]  / $ratio);  
$src=ImageCreateFromPNG("$src/$entry");  
$img = ImageCreateTrueColor($new_width,$new_height);  
ImageCopyRESAMPLED($img,$src,0,0,0,0,($new_width-1),($new_height-1),$size[0],$size[1]);  
$new_src=($path.$prefix.$entry);  
ImagePNG($img,$new_src,75);  
ImageDestroy($img);  
ImageDestroy($src);  
}//End check for exising thumbnail  
}  
}  
  
$filenam = $NewRecord1->FileUpload1->GetValue();  
  
if($filenam){  
thumbbeshoo("$filenam",'images/upload/','images/thump/','','60','75');  
typeonimg("images/upload/".$filenam,"Copyright 2005 (C)","images/upload/".$filenam);  
  
}  
  
  
// -------------------------  
//End Custom Code

And

//Custom Code @15-FF3FD3DA  
// -------------------------  
    global $NewRecord1;  
$filenam = $NewRecord1->FileUpload1->GetValue();  
  
if($filenam){  
@unlink("images/thump/".$filenam);  
}  
  
  
// -------------------------  
//End Custom Code  

And
//Custom Code @22-FF3FD3DA  
// -------------------------  
    global $NewRecord1;  
  
$delete = $NewRecord1->todel->GetValue();  
if($delete){  
@unlink("images/thump/".$delete);  
}  
  
// -------------------------  
//End Custom Code  

Adjust label1 src to:
images/upload/{Label1_Src}

Adjust label2 src to:
images/thump/{Label2}

Adjust Fileupload temp folder to:
images/tmp/

Adjust Fileupload image folder to
images/upload/

Create the following folders in your webroot
images
images/upload
images/tmp
images/thump

Regards,
Frans
tset tpo
Posted: 11/17/2005, 8:51 AM

thank you beshoo

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.