Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
A tiny Little Bit Of Help Please
Old 11-15-2005, 05:13 PM A tiny Little Bit Of Help Please
MrRundog's Avatar
Average Talker

Posts: 19
Trades: 0
I have the following code to upload a pic

Code:
    	
if ($_SERVER['REQUEST_METHOD'] == "POST")
    { 
$size = 150; // the thumbnail height
$filedir = '../kill/'; // the directory for the original image
$thumbdir = '../uploads/'; // the directory for the thumbnail image
$prefixct= $_POST['PartNum']; // the prefix to be  added to the original name
$prefixpn = '-';
$maxfile = '512000';
$mode = '0666';


$userfile_name = $_FILES['image']['name'];
$userfile_tmp = $_FILES['image']['tmp_name'];
$userfile_size = $_FILES['image']['size'];
$userfile_type = $_FILES['image']['type'];
    if (isset($_FILES['image']['name']))
     	{
         	$prod_img = $filedir.$userfile_name;
         	$prod_img_thumb = $thumbdir.$prefixct.$prefixpn.$userfile_name;
             $mysqlpath=$prefixct.$prefixpn.$userfile_name;
         	move_uploaded_file($userfile_tmp, $prod_img);
         	chmod ($prod_img, octdec($mode));
         	$sizes = getimagesize($prod_img);
         	$aspect_ratio = $sizes[1]/$sizes[0];
         	   if ($sizes[1] <= $size)
         	   {
                $new_width = $sizes[0];
                $new_height = $sizes[1];
         	   }else{
                $new_height = $size;
                $new_width = abs($new_height/$aspect_ratio);
         	   }

$destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image');
$srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image');
ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving');
imagedestroy($destimg);

     		}
This works fine - What I am having a problem with is adding the $_POST['PartNum']; as a prefix to the original image - any thoughts? (either before or after making the thumb.

Cheers
Andy

Last edited by MrRundog; 11-15-2005 at 05:32 PM..
MrRundog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-15-2005, 05:29 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
[php]$prefixct= $_POST['PartNum'];//
$prefixct = ''; // the prefix to be added to the original name
[php]

You do realize that the second one overwrites the first right?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 11-15-2005, 05:33 PM Yeah
MrRundog's Avatar
Average Talker

Posts: 19
Trades: 0
Yeah sorry - the code moved the original was on the same line as //
MrRundog is offline
Reply With Quote
View Public Profile
 
Old 11-16-2005, 09:13 AM
MrRundog's Avatar
Average Talker

Posts: 19
Trades: 0
SOLVED

move_uploaded_file($userfile_tmp, $prod_img);

Change this to any file name
__________________
"Tell Me & I Forget; Show Me & I Remember; Involve Me & I Understand"


Please login or register to view this content. Registration is FREE
MrRundog is offline
Reply With Quote
View Public Profile
 
Old 11-16-2005, 11:39 PM
Experienced Talker

Posts: 46
Trades: 0
If I understand you correctly. Are you trying to change the original image name into something else... If so..
You will have to change it before you convert it into a thumbnail.
To do this I would use the explode() function to break appart $_FILES['image']['name'];

example
$_POST['name'] = 'myimage';
$_FILES['image']['name'] = 'imagename.jpg';

$x = explode(".", $_FILES['image']['name']); // It breaks appart name and converts to an array

$x[0] //imagename
$x[1] //jpg

$newname = $_POST['name'] "." $x[1]; //myimage.jpg

$_FILES['image']['name'] = $newname;

Then perform the rest of your code...
__________________

Please login or register to view this content. Registration is FREE
- Need a place to post an ad?


Please login or register to view this content. Registration is FREE
- make money off you designs! Logos, web templates and more!
karnetics is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to A tiny Little Bit Of Help Please
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.92377 seconds with 12 queries