/    Sign up×
Community /Pin to ProfileBookmark

Uploading an image to another server?

Hi,

I was wondering, if it possible to upload an image from my server to a different server.

Example: –
Someone goes to my website, they enter the details. I then put there details in my database and then I have an image file upload onto another server. So somehow i need to call the script (which is below) from another server.

I cant however locate the form to this upload page on the other server as i need to put things into my database, I know i cant upload the image from my server to there because of the permisions, which is why i thought of puttin an upload function on the other server for me to call. The thing is im not sure how to call this function and pass over the image to it that i have just uploaded?

Thanks
Adam

[code=php]
function uploadImg() {

// Sort out the image
$size = 125; // the thumbnail height

$filedir = CUSTOMERS_HTTP_SERVER . CUSTOMERS_DIR_WS_HTTP_CATALOG . CUSTOMERS_DIR_WS_CATALOG_IMAGES; // the directory for the original image
$thumbdir = CUSTOMERS_HTTP_SERVER . CUSTOMERS_DIR_WS_HTTP_CATALOG . CUSTOMERS_DIR_WS_CATALOG_IMAGES; // the directory for the thumbnail image

$maxfile = ‘2000000’;
$mode = ‘0666’;

$ImageExt = explode(“.”,$_FILES[‘ProductImage’][‘name’]);
$ImageExt = ‘.’ . $ImageExt[1];

$userfile_name_F = ($GetNewProduct_ID + CUSTOMERS_PID_OFFSET) . ‘_F’ . $ImageExt;
$userfile_name_T = ($GetNewProduct_ID + CUSTOMERS_PID_OFFSET) . ‘_T’ . $ImageExt;
$userfile_name = ($GetNewProduct_ID + CUSTOMERS_PID_OFFSET) . $ImageExt;
$userfile_tmp = $_FILES[‘ProductImage’][‘tmp_name’];
$userfile_size = $_FILES[‘ProductImage’][‘size’];
$userfile_type = $_FILES[‘ProductImage’][‘type’];

if (isset($_FILES[‘ProductImage’][‘name’])) {

$prod_img = $filedir . $userfile_name_F;

$prod_img_thumb = $thumbdir . $userfile_name_T;
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);
}
}
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@k0r54authorApr 25.2006 — ok,

Well i think i can do it but.. i got a small problem, i am using require and location to the file at the other server. It finds the file and there is no error, but when i try and call the function within that file it fails and says it is undefined? why is that when it can see the file fine?
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...