02-25-2008, 02:33 AM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Feb 2008
Posts: 13
Thanks: 3
|
Host Upgraded - File Upload won't work now
I have had my site working for MANY years until recently my host had upgraded the server to PHP 5. Sicne then I can't get a simple file upload to work? Can anyone look at this code and tell me why it wouldn't work?
The error I am getting is " Sorry. You did not chose an image" which I am assuming means the file string isn't being passed on??? But the weirder thing is I am getting the "Ad uploaded" message also? So it's telling me there is an error but also saying it was uploaded (which it isn't).
PHP Code:
<?php
$adtitle = $_POST['adtitle'];
$adtype = $_POST['adtype'];
$imagetype = $_POST['imagetype'];
$adimagefile = $_POST['adimagefile'];
$url = $_POST['url'];
$groupid = $_POST['groupid'];
$error = false;
$errormessage = "";
if (strlen($adtitle) < 1) {
$error = true;
$errormessage .= "<li><b>Sorry. You did not enter an ad title.</b><br>\n";
}
if ($adtype == 'A'){
if (strlen($code) < 1) {
$error = true;
$errormessage .= "<li><b>Sorry. You did not enter an affiliate code.</b><br>\n";
}
}
if ($adtype == 'O'){
if (strlen($adimagefile) < 1) {
$error = true;
// HERE"S MY ERROR!!!!!
$errormessage .= "<li><b>Sorry. You did not chose an image</b><br>\n";
}
if ($imagetype == "") {
$error = true;
$errormessage .= "<li><b>Sorry. You did not chose an image type.</b><br>\n";
}
if (strlen($url) < 1) {
$error = true;
$errormessage .= "<li><b>Sorry. You did enter a URL</b><br>\n";
}
}
?>
<h2>Save new ad</h2>
<p>
<?php
$adid = nextid("ads", "adid");
if($adtype == 'O'){
// HERE's MY UPLOAD
$newfilename = "../ads/$adid.$imagetype";
$picfile = $HTTP_POST_FILES['userfile']['tmp_name'];
copy($adimagefile, $newfilename);
printf("Ad uploaded<br>");
}
if ($error) {
printf("<font color=red>There was a problem creating the ad!</font><br><br>Please click on back in your browser to fix the problems listed below.<br>");
printf($errormessage);
} else {
if ($adtype == 'A'){
$sql = "insert into ads (adid, code, impressions, clicks, groupid, type, name) values ($adid, '$code', 1, 1, $groupid, '$adtype', '$adtitle')";
}
if ($adtype == 'O'){
$newurl = "http://";
$newurl .= $url;
$sql = "insert into ads (adid, image, url, impressions, clicks, groupid, type, name) values ($adid, '$imagetype', '$newurl', 1, 1, $groupid, '$adtype', '$adtitle')";
}
$result = mysql_query($sql ,$db);
printf("<p>The ad has been added to the group.</p>");
printf("<p><a href=editadgroup.php?groupid=$groupid>Back to ad group</a></p>");
}
?>
</p>
|
|
|
|