Hey all,
I want to upload images to an external sever for my website. The images will be user uploadable through my website then I need to transfer them to another web server, to save bandwidth costs. How would I go about doing this? This is my current image script:
<?php
include("includes/connectdb.php");
if ($error==NULL)
{
$timestart=time();
mysql_query(" insert into classifieds
( status, title, guitar, price, timestart, timeend, condition, tremlo, yearmade, serialno,
countryorigin, originalparts, necktype, description, postageprice, postageservice,
postalinsurance, collection, userid, link1, link2, link3, link4)
values
('1','$title', '$guitar', '$price', '$timestart', '$duration', '$condition', '$tremlo'
, '$yearmade', '$serialno', '$countryorigin', '$originalparts', '$necktype',
'$description', '$postageprice', '$postageservice', '$postalinsurance',
'$collection', '$userid', '$linkarray[1]', '$linkarray[2]', '$linkarray[3]', '$linkarray[4]') ")
or print ( mysql_error() );
if ($empty!="Y") {
$info=mysql_query("select * from classifieds where title='$title' and price='$price' and description='$description'");
while ($row=mysql_fetch_array($info))
{
$classid=$row[id];
}
$i=0;
$imagepath="C:/phpdev/www/templatesite/ftpupload/$classid/";
while ($i<=$numphotos)
{
if ($i==0 ) { mkdir("$imagepath", 077 ); }
move_uploaded_file( $array[$i] , "C:/phpdev/www/templatesite/ftpupload/$classid/$i.jpg");
$i++;
}
$photo="insert into classphotos (id, numphotos";
$i=1;
while ($i<=$numphotos)
{
$photo .= ",photo";
$photo .= $i;
$i++;
}
$photo .= ") values ('";
$photo .= $classid;
$photo .="','";
$photo .= $numphotos;
$photo .="'";
$i=1;
while ($i<=$numphotos)
{
$photo .= ",'";
$photo .= $imagepath;
$photo .= $i;
$photo .= ".jpg";
$photo .= "'";
$i++;
}
$photo .= ")";
mysql_query("$photo") or die (mysql_error() );
}
}
else { print "<script> location.href='listguitar.php?error=$error' </script>"; die("$error"); }
?>
Also any code critique would be helpful too!!!
Thanks in advance.
Jack