...

View Full Version : Remote Upload Help!



Chris-2k
08-14-2012, 05:11 PM
Heyya all,

my remote code isn't working, filename errors, here's my code in uploader.php

if (isset($_POST['remoteimage']) && !empty($_POST['remoteimage'])) {
$image_urls = explode('\n', $_POST['remoteimage']);

foreach($image_urls AS $sURL)
{
$sURL = trim($sURL);
if (!empty($sURL)) {
performUploadandCreateThumb($image_urls, $aConfig);
}
}
} // < attempting a remote upload and all checks.

and here's my func:

function performUploadandCreateThumb($files, array $aConfig) {
if($ext = checkitsaValidImage($files, $aConfig)) {
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin) {
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id)) {
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name);
// Insert to DB
insertDBinfo($files, $aConfig, $new_name);
} else {
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;

// Create the thumbnail
if(is_numeric($_POST['maxdimensions'])) {
create_thumb($imageRetrieve, $new_name, $sToDir);
}
if(isset($_POST['email'])) {
sendImageToEmail($url, $$thumb, $aConfig);
}
showImageInfo($imageRetrieve);

include THEME_DIR .'uploaded.php';
} else {
if(loggedin()) {
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id)) {
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload File
copy($files, $aConfig['upload_destination'] .'/'. $album_id . $new_name);
} else {
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
copy($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;

// Create the thumbnail
if(is_numeric($_POST['maxdimensions'])) {
create_thumb($imageRetrieve, $new_name, $sToDir);
}
if(isset($_POST['email'])) {
sendImageToEmail($url, $$thumb, $aConfig);
}
showImageInfo($imageRetrieve);

include THEME_DIR .'uploaded.php';

unlink($files);
}
}

can any1 help, thx

Fou-Lu
08-14-2012, 05:32 PM
What is the error and on what line?

Chris-2k
08-14-2012, 05:47 PM
here's the main error:


Warning: copy() [function.copy]: Filename cannot be empty in /home/sonicimg/public_html/includes/functions.php on line 652

Fou-Lu
08-14-2012, 06:09 PM
Too bad it doesn't specify which is no good.
Given what you have here, so long as these indentations are correct (I don't want to count braces this morning), the problem is $new_name and $album_id are null.

tangoforce
08-14-2012, 06:51 PM
so long as these indentations are correct (I don't want to count braces this morning)

Thats why I've stayed out of this.

All I will say to you Chris is that the style you use for your braces is not a good one and its not easy to follow either.

See the coding styles link in my signature for a good demonstration as to why its better to put the braces on seperate lines and matching up. It will make your life a lot easier.

Chris-2k
08-14-2012, 08:40 PM
ok this func is modifie,,, still get error

function performUploadandCreateThumb($files, array $aConfig) {
if($ext = checkitsaValidImage($files, $aConfig))
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin)
{
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name);
// Insert to DB
insertDBinfo($files, $aConfig, $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;
}
else
{
if($ext = checkitsaValidImage($files, $aConfig))
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin())
{
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload File
copy($files, $aConfig['upload_destination'] .'/'. $album_id . $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
copy($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;

unlink($files);
}
}

// Create the thumbnail
if(is_numeric($_POST['maxdimensions']))
{
create_thumb($imageRetrieve, $new_name, $sToDir);
}
if(isset($_POST['email']))
{
sendImageToEmail($url, $$thumb, $aConfig);
}
showImageInfo($imageRetrieve);

include THEME_DIR .'uploaded.php';
}

Fou-Lu
08-14-2012, 08:55 PM
Half of my previous comment still stands. Where is $album_id defined within that else branch?

Chris-2k
08-14-2012, 09:47 PM
ah yea, modified:

function performUploadandCreateThumb($files, array $aConfig) {
if($ext = checkitsaValidImage($files, $aConfig))
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin)
{
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name);
// Insert to DB
insertDBinfo($files, $aConfig, $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;
}
else
{
if($ext = checkitsaValidImage($files, $aConfig))
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin())
{
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload File
copy($files, $aConfig['upload_destination'] .'/'. $album_id . $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
copy($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;

unlink($files);
}
}

// Create the thumbnail
if(is_numeric($_POST['maxdimensions']))
{
create_thumb($imageRetrieve, $new_name, $sToDir);
}
if(isset($_POST['email']))
{
sendImageToEmail($url, $$thumb, $aConfig);
}
showImageInfo($imageRetrieve);

include THEME_DIR .'uploaded.php';
}

still im getting:


Warning: getimagesize() [function.getimagesize]: Filename cannot be empty

Fou-Lu
08-14-2012, 10:07 PM
There is no call in here to getimagesize. Your error is now elsewhere. The error will include the file and approximate line number.

Chris-2k
08-14-2012, 10:20 PM
hi, im getting all these:


Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /home/sonicimg/public_html/includes/functions.php on line 345

Warning: Division by zero in /home/sonicimg/public_html/includes/functions.php on line 357

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/sonicimg/public_html/includes/functions.php on line 367

Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/sonicimg/public_html/includes/functions.php on line 370

Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /home/sonicimg/public_html/includes/functions.php on line 373

Warning: imagedestroy() expects parameter 1 to be resource, boolean given in /home/sonicimg/public_html/includes/functions.php on line 376

Warning: imagedestroy() expects parameter 1 to be resource, null given in /home/sonicimg/public_html/includes/functions.php on line 377

Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /home/sonicimg/public_html/includes/functions.php on line 397



because the file aint even saving locally on my server, i've checked....

any idea.............

Fou-Lu
08-14-2012, 10:28 PM
Lets take a look at your current code then.
There is a section here that makes no sense:


if($ext = checkitsaValidImage($files, $aConfig))
{
}
else
{
if($ext = checkitsaValidImage($files, $aConfig))
{
}
// nothing here.
}

It cannot be true and false. If it doesn't pass the first if check, then it will do nothing in the else since you request the same function to verify again. There is no else processing for this nested branch.

Chris-2k
08-14-2012, 10:47 PM
okk ive removed that:

function performUploadandCreateThumb($files, array $aConfig) {
if($ext = checkitsaValidImage($files, $aConfig))
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin)
{
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name);
// Insert to DB
insertDBinfo($files, $aConfig, $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;
}
else
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin())
{
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload File
copy($files, $aConfig['upload_destination'] .'/'. $album_id . $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
copy($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;

unlink($files);
}

// Create the thumbnail
if(is_numeric($_POST['maxdimensions']))
{
create_thumb($imageRetrieve, $new_name, $sToDir);
}
if(isset($_POST['email']))
{
sendImageToEmail($url, $$thumb, $aConfig);
}
showImageInfo($imageRetrieve);

include THEME_DIR .'uploaded.php';
}

the file is stillnot being saved.

Fou-Lu
08-14-2012, 11:39 PM
What is your current error? Is it from the copy? copy itself should work with http wrappers as it relies on fopen, but the ini specification for allow_url_fopen has to be enabled for it to work.

Also, in that else the $ext will be false, null or equivalent. The variable will be set, but will evaluate to nothing. Whilst this is not a problem as the extension isn't required on a file, it may change handling if you expect an extension to exist.

Chris-2k
08-15-2012, 12:40 AM
here's all my errors:


Warning: copy() [function.copy]: Filename cannot be empty in /home/sonicimg/public_html/includes/functions.php on line 654

Warning: unlink() [function.unlink]: No such file or directory in /home/sonicimg/public_html/includes/functions.php on line 660

Warning: getimagesize(i293/q31yo) [function.getimagesize]: failed to open stream: No such file or directory in /home/sonicimg/public_html/includes/functions.php on line 345

Warning: Division by zero in /home/sonicimg/public_html/includes/functions.php on line 357

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/sonicimg/public_html/includes/functions.php on line 367

Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/sonicimg/public_html/includes/functions.php on line 370

Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /home/sonicimg/public_html/includes/functions.php on line 373

Warning: imagedestroy() expects parameter 1 to be resource, boolean given in /home/sonicimg/public_html/includes/functions.php on line 376

Warning: imagedestroy() expects parameter 1 to be resource, null given in /home/sonicimg/public_html/includes/functions.php on line 377

Warning: getimagesize(i293/q31yo) [function.getimagesize]: failed to open stream: No such file or directory in /home/sonicimg/public_html/includes/functions.php on line 397

Warning: filesize() [function.filesize]: stat failed for i293/q31yo in /home/sonicimg/public_html/includes/functions.php on line 398

Warning: Division by zero in /home/sonicimg/public_html/includes/functions.php on line 431

from there, it's grabbing a filename; no extension but not saving.

Fou-Lu
08-15-2012, 01:14 AM
Print this before the copy's and post the results:


printf('Copy %s to %s', $files, $aConfig['upload_destination'] .'/'. $album_id . $new_name);


What is this result?

Chris-2k
08-15-2012, 01:38 AM
this wht i get:



Copy to i293/teayr

Fou-Lu
08-15-2012, 04:09 PM
Then the $files you have provided to the function is no good or it has been altered before use.

If this is exactly the code you use to call it, then it is either caused by a second call to this same function, or that $files has been altered. Only place I can see that it is possibly changed is within the call to checkitsaValidImage.

Chris-2k
08-16-2012, 02:29 AM
hi

i've got it working using curl:

function performUploadandCreateThumb($files, array $aConfig) {
if($ext = checkitsaValidImage($files, $aConfig))
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin)
{
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name);
// Insert to DB
insertDBinfo($files, $aConfig, $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;
}
else
{
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin())
{
$album_id = $_POST['album_id'];
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Download the file(s).
$ch = curl_init($files);
// Save the file(s).
$fp = fopen($aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name, "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Download the file(s).
$ch = curl_init($files);
// Save the file(s).
$fp = fopen($aConfig['upload_destination'] .'/'. $new_name, "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;

unlink($files);
}

// Create the thumbnail
if(is_numeric($_POST['maxdimensions']))
{
create_thumb($imageRetrieve, $new_name, $sToDir);
}
if(isset($_POST['email']))
{
sendImageToEmail($url, $$thumb, $aConfig);
}
showImageInfo($imageRetrieve);

include THEME_DIR .'uploaded.php';
}

now can 1 tell me how to get the extension, as it's only saving filename.

Chris-2k
08-16-2012, 10:48 PM
hi,

hope someone can help me now, i've done a test well an echo $files; and for local image it gives th tmp_name as expected............

for remote it gives nothing, why?????

function performUploadandCreateThumb($files, array $aConfig)
{
echo 'file '.$files;
if($ext = checkitsaValidImage($files, $aConfig))
{
$album_id = $_POST['album_id'];
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin)
{
if(!is_dir($aConfig['upload_destination'] .'/'. $album_id) && !is_dir($aConfig['thumb_destination'] .'/'. $album_id))
{
mkdir($aConfig['upload_destination'] .'/'. $album_id, 0777);
mkdir($aConfig['thumb_destination'] .'/'. $album_id, 0777);
}
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/'. $album_id .'/thumb_'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/'. $album_id .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name);
// Insert to DB
insertDBinfo($files, $aConfig, $new_name);
}
else
{
$filePath = $aConfig['site_address'] .'/'. $aConfig['upload_destination'] .'/'. $new_name;
$imageRetrieve = $aConfig['upload_destination'] .'/'. $new_name;
$thumbfilePath = $aConfig['site_address'] .'/'. $aConfig['thumb_destination'] .'/thumb'. $new_name;
$saveTo = $aConfig['thumb_destination'] .'/';
// Upload image
move_uploaded_file($files, $aConfig['upload_destination'] .'/'. $new_name);
}
$url = $filePath;
$thumb = $thumbfilePath;
$sToDir = $saveTo;
}
else
{
echo 'f '.$files;
// $ext = ShowFileExtension($files);
// echo 'ext- '. $ext;
$new_name = generateUniqueFilename() . $ext; // we will give an unique name.
if(loggedin())
{
// Download the file(s).
$ch = curl_init($files);
// Save the file(s).
$fp = fopen($aConfig['upload_destination'] .'/'. $album_id .'/'. $new_name, "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
}
else
{
// Download the file(s).
$ch = curl_init($files);
// Save the file(s).
$fp = fopen($aConfig['upload_destination'] .'/'. $new_name, "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
}
}

// Create the thumbnail
if(is_numeric($_POST['maxdimensions']))
{
// create_thumb($imageRetrieve, $new_name, $sToDir);
}
if(isset($_POST['email']))
{
sendImageToEmail($url, $thumb, $aConfig);
}
showImageInfo($imageRetrieve);

include THEME_DIR .'uploaded.php';
}


please help...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum