gpt4 book ai didi

javascript - 为什么我被 403 禁止?

转载 作者:行者123 更新时间:2023-11-28 16:29:09 26 4
gpt4 key购买 nike

我正在开发 Mario Kart Wii 许可证制作器,每当我添加一个按钮将其保存到我的服务器时,它就可以在我的 http://localhost 上运行。但是当我将它上传到我的网站时,它给了我。如果对您有帮助,这是我使用的 HTML/PHP、CSS 和 JavaScript。

$(document).ready(function(){

var canvas = document.getElementById("mainCanvas");
var ctx = canvas.getContext("2d");

var name = document.getElementById("name");
var favRace = document.getElementById("favRace");
var vr = document.getElementById("vrPoints");
var ranking = document.getElementById("ranking");
var favVehicle = document.getElementById("favKart");
var favVehicle2 = document.getElementById("favKart2");
var bgrnd = document.getElementById("bgrnd");
var textClr = document.getElementById("textClr");
var favChar = document.getElementById("favChar");
var secChar = document.getElementById("secChar");
var mainImg = document.getElementById("mainImg");

$("#create").click(function(){
drawRect(0, 0, bgrnd.value, 530, 300);
drawRect(0, 0, "white", 163, 173);
switch (favChar.value) {
case "Yoshi":
img = document.getElementById("yoshi");
break;
case "Baby Luigi":
img = document.getElementById("baby_luigi");
break;
case "Baby Daisy":
img = document.getElementById("baby_daisy");
break;
case "Baby Peach":
img = document.getElementById("baby_peach");
break;
case "Baby Mario":
img = document.getElementById("baby_mario");
break;
case "Toad":
img = document.getElementById("toad");
break;
case "Toadette":
img = document.getElementById("toadette");
break;
case "Koopa Troopa":
img = document.getElementById("koopa_troopa");
break;
case "Dry Bones":
img = document.getElementById("dry_bones");
break;
case "Mario":
img = document.getElementById("mario");
break;
case "Luigi":
img = document.getElementById("luigi");
break;
case "Peach":
img = document.getElementById("peach");
break;
case "Daisy":
img = document.getElementById("daisy");
break;
case "Birdo":
img = document.getElementById("birdo");
break;
case "Diddy Kong":
img = document.getElementById("diddy");
break;
case "Bowser Jr.":
img = document.getElementById("bowser_jr");
break;
case "Wario":
img = document.getElementById("wario");
break;
case "Waluigi":
img = document.getElementById("waluigi");
break;
case "Donkey Kong":
img = document.getElementById("dk");
break;
case "Bowser":
img = document.getElementById("bowser");
break;
case "King Boo":
img = document.getElementById("boo");
break;
case "Rosalina":
img = document.getElementById("rosalina");
break;
case "Funky Kong":
img = document.getElementById("funky");
break;
case "Dry Bowser":
img = document.getElementById("dry_bowser");
break;
case "Mii":
img = document.getElementById("mii");
break;
default:
img = "null";
}

drawText("Name: " + name.value, 170, 20, textClr.value, "17px Times");
drawText("Favorite Race: " + favRace.value, 170, 45, textClr.value, "17px Times");
drawText("Favorite Vehicle: " + favVehicle.value, 170, 70, textClr.value, "17px Times");
drawText("Secondary Character: " + secChar.value, 170, 95, textClr.value, "17px Times")
drawText("Secondary Vehicle: " + favVehicle2.value, 170, 120, textClr.value, "17px Times");
drawText("Overall Ranking: " + ranking.value, 170, 145, textClr.value, "17px Times");
drawText("Versus Points: " + vr.value, 170, 170, textClr.value, "17px Times");
drawImg(img, 8, 8, 150, 160);
ctx.strokeRect(0, 0, 530, 300);
drawText("Mario Kart Wii", 20, 260, textClr.value, "75px Bandits");
document.getElementById("canvasP").style.display = "block";
document.getElementById("share").style.display = "block";
canvas.style.display = "initial";
var imageURL = canvas.toDataURL();
document.getElementById("image").value = imageURL;

});

function drawRect(x, y, color, width, height) {
ctx.fillStyle = color;
ctx.fillRect(x, y, width, height);
}

function drawText(text, x, y, color, font) {
ctx.fillStyle = color;
ctx.font = font;
ctx.fillText(text, x, y);
}

function drawImg(img, x, y, width, height) {
ctx.drawImage(img, x, y, width, height);
ctx.strokeRect(0, 0, width + 14, height + 14);
ctx.strokeStyle = "black";
ctx.lineWidth = 5;
}

});
@font-face {
font-family: Bandits;
src: url("Bandits.ttf");
font-weight: bold;
}

#mainCanvas {
display: none;
}

#canvasP {
display: none;
}

.img {
display: none;
}

a {
text-decoration: none;
}

header {
background: -linear-gradient(#EEEEEE, #DDDDDD);
background: -webkit-linear-gradient(#EEEEEE, #DDDDDD);
height: 50px;
margin: -.6%;
padding: 10px;
}

#title {
font-family: Bandits;
font-size: 55px;
color: #585858;
}

body {
background-color: rgb(134, 170, 230);
}

fieldset {
width: 60%;
text-align: left;
}

.yellow {
color: yellow;
}

#license {
border: 2px solid black;
border-radius: 5px;
}

#share {
display: none;
}
<?PHP

function share() {
if (!empty($_POST)) {
define('UPLOAD_DIR', '');
define('UPLOAD_DIR2', 'licenses/');
$img = $_POST['image'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . 'share.png';
$licenses = UPLOAD_DIR2 . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save file.';
}
}

?>

<!DOCTYPE HTML>
<HTML lang = "en">
<head>
<meta charset = "UTF-8">
<meta name = "description" content = "Create Mario Kart Wii Licenses!">
<meta name = "author" content = "Adam Oates">
<meta name = "title" content = "Mario Kart Wii License Maker">
<title title = "Mario Kart Wii License Maker | Gigaboy Web Designs">
Mario Kart Wii License Maker | Gigaboy Web Designs
</title>
<link rel = "apple-touch-icon" href = "images/logo.png">
<link rel = "shortcut icon" href = "images/logo.png">
<link rel = "stylesheet" type = "text/css" href = "main.css">
<script type = "text/javascript" src = "https://apis.google.com/js/platform.js" async defer></script>
<script type = "text/javascript" src = "http://code.jquery.com/jquery-2.1.4.js"></script>
<script type = "text/javascript" src = "main.js"></script>
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
xfbml : true,
version : 'v2.5'
});
};

(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<header>
<div id = "title">
MKWii License Maker
</div>
</header><br><br><br><br>

<section>
<div align = "center">
<form action = "" method = "post">
<fieldset>
Name: <input type = "text" name = "name" id = "name" placeholder = "Name"><br><br>
Favorite Race: <select id = "favRace">
<optgroup label = "Mushroom Cup">
<option value = "Luigi Circuit">Luigi Circuit</option>
<option value = "Moo Moo Meadows">Moo Moo Meadows</option>
<option value = "Mushroom Gorge">Mushroom Gorge</option>
<option value = "Toad's Factory">Toad's Factory</option>
<optgroup label = "Flower Cup">
<option value = "Mario Circuit">Mario Circuit</option>
<option value = "Coconut Mall">Coconut Mall</option>
<option value = "DK's Summit">DK's Summit</option>
<option value = "Wario's Gold Mine">Wario's Gold Mine</option>
<optgroup label = "Star Cup">
<option value = "Daisy Circuit">Daisy Circuit</option>
<option value = "Koopa Cape">Koopa Cape</option>
<option value = "Maple Treeway">Maple Treeway</option>
<option value = "Grumble Volcano">Grumble Volcano</option>
<optgroup label = "Special Cup">
<option value = "Dry Dry Ruins">Dry Dry Ruins</option>
<option value = "Moonview Highway">Moonview Highway</option>
<option value = "Bowser's Castle">Bowser's Castle</option>
<option value = "Rainbow Road">Rainbow Road</option>
<optgroup label = "Shell Cup">
<option value = "GCN Peach Beach">GCN Peach Beach</option>
<option value = "DS Yoshi Falls">DS Yoshi Falls</option>
<option value = "SNES Ghost Valley 2">SNES Ghost Valley 2</option>
<option value = "N64 Mario Raceway">N64 Mario Raceway</option>
<optgroup label = "Bannana Cup">
<option value = "N64 Sherbert Land">N64 Sherbert Land</option>
<option value = "GBA Shy Guy Beach">GBA Shy Guy Beach</option>
<option value = "DS Delfino Square">DS Delfino Square</option>
<option value = "GCN Waluigi Stadium">GCN Waluigi Stadium</option>
<optgroup label = "Leaf Cup">
<option value = "DS Desert Hill">DS Desert Hill</option>
<option value = "GBA Bowser's Castle 3">GBA Bowser's Castle 3</option>
<option value = "N64 DK Jungle Parkway">N64 DK Jungle Parkway</option>
<option value = "GCN Mario Circuit">GCN Mario Circuit</option>
<optgroup label = "Lightning Cup">
<option value = "SNES Mario Circuit 3">SNES Mario Circuit 3</option>
<option value = "DS Peach's Garden">DS Peach's Garden</option>
<option value = "GCN DK Mountain">GCN DK Mountain</option>
<option value = "N64 Bowser's Castle">N64 Bowser's Castle</option>
</select><br><br>
Overall Ranking: <select id = "ranking">
<option id = "e" value = "E">E</option>
<option id = "d" value = "D">D</option>
<option id = "c" value = "C">C</option>
<option id = "b" value = "B">B</option>
<option id = "a" value = "A">A</option>
<option id = "star1" value = "&#9733;">&#9733;</option>
<option id = "star2" value = "&#9733;&#9733;">&#9733;&#9733;</option>
<option id = "star3" value = "&#9733;&#9733;&#9733;">&#9733;&#9733;&#9733;</option>
</select><br><br>
Versus Points: <select id = "vrPoints">
<option id = "1000+" value = "1000+">1000+</option>
<option id = "2000+" value = "2000+">2000+</option>
<option id = "3000+" value = "3000+">3000+</option>
<option id = "4000+" value = "4000+">4000+</option>
<option id = "5000+" value = "5000+">5000+</option>
<option id = "6000+" value = "6000+">6000+</option>
<option id = "7000+" value = "7000+">7000+</option>
<option id = "8000+" value = "8000+">8000+</option>
<option id = "9000+" value = "9000+">9000+</option>
</select><br><br>
Favorite Character: <select id = "favChar">
<option value = "Baby Mario">Baby Mario</option>
<option value = "Baby Luigi">Baby Luigi</option>
<option value = "Baby Peach">Baby Peach</option>
<option value = "Baby Daisy">Baby Daisy</option>
<option value = "Toad">Toad</option>
<option value = "Toadette">Toadette</option>
<option value = "Koopa Troopa">Koopa Troopa</option>
<option value = "Dry Bones">Dry Bones</option>
<option value = "Mario">Mario</option>
<option value = "Luigi">Luigi</option>
<option value = "Peach">Peach</option>
<option value = "Daisy">Daisy</option>
<option value = "Yoshi">Yoshi</option>
<option value = "Birdo">Birdo</option>
<option value = "Diddy Kong">Diddy Kong</option>
<option value = "Bowser Jr.">Bowser Jr.</option>
<option value = "Wario">Wario</option>
<option value = "Waluigi">Waluigi</option>
<option value = "Donkey Kong">Donkey Kong</option>
<option value = "Bowser">Bowser</option>
<option value = "King Boo">King Boo</option>
<option value = "Rosalina">Rosalina</option>
<option value = "Funky Kong">Funky Kong</option>
<option value = "Dry Bowser">Dry Bowser</option>
<option value = "Mii">Mii</option>
</select><br><br>
Secondary Character: <select id = "secChar">
<option value = "Baby Mario">Baby Mario</option>
<option value = "Baby Luigi">Baby Luigi</option>
<option value = "Baby Peach">Baby Peach</option>
<option value = "Baby Daisy">Baby Daisy</option>
<option value = "Toad">Toad</option>
<option value = "Toadette">Toadette</option>
<option value = "Koopa Troopa">Koopa Troopa</option>
<option value = "Dry Bones">Dry Bones</option>
<option value = "Mario">Mario</option>
<option value = "Luigi">Luigi</option>
<option value = "Peach">Peach</option>
<option value = "Daisy">Daisy</option>
<option value = "Yoshi">Yoshi</option>
<option value = "Birdo">Birdo</option>
<option value = "Diddy Kong">Diddy Kong</option>
<option value = "Bowser Jr.">Bowser Jr.</option>
<option value = "Wario">Wario</option>
<option value = "Waluigi">Waluigi</option>
<option value = "Donkey Kong">Donkey Kong</option>
<option value = "Bowser">Bowser</option>
<option value = "King Boo">King Boo</option>
<option value = "Rosalina">Rosalina</option>
<option value = "Funky Kong">Funky Kong</option>
<option value = "Dry Bowser">Dry Bowser</option>
<option value = "Mii">Mii</option>
</select><br><br>
Vehichle Used For Favorite Character: <select id = "favKart">
<optgroup label = "Light Weight">
<option value = "Standard Kart S" id = "sks">Standard Kart S</option>
<option value = "Booster Seat" id = "bseat">Booster Seat</option>
<option value = "Mini Beast" id = "mb">Mini Beast</option>
<option value = "Cheap Charger" id = "cc">Cheap Charger</option>
<option value = "Tiny Titan" id = "tt">Tiny Titan</option>
<option value = "Blue Falcon" id = "bf">Blue Falcon</option>
<option value = "Standard Bike S" id = "sbs">Standard Bike S</option>
<option value = "Bullet Bike" id = "bb">Bullet Bike</option>
<option value = "Bit Bike" id = "bitb">Bit Bike</option>
<option value = "Quacker" id = "qkr">Quacker</option>
<option value = "Magikruser" id = "mgcCrsr">Magikruser</option>
<option value = "Jet Bubble" id = "jb">Jet Bubble</option>
<optgroup label = "Medium Weight">
<option value = "Standard Kart M" id = "skm">Standard Kart M</option>
<option value = "Classic Dragster" id = "cd">Classic Dragster</option>
<option value = "Wild Wing" id = "ww">Wild Wing</option>
<option value = "Super Blooper" id = "sb">Super Blooper</option>
<option value = "Daytripper" id = "dtrp">Daytripper</option>
<option value = "Sprinter" id = "sprnt">Sprinter</option>
<option value = "Standard Bike M" id = "sbm">Standard Bike M</option>
<option value = "Mach Bike" id = "machb">Mach Bike</option>
<option value = "Sugarscoot" id = "sugar">Sugarscoot</option>
<option value = "Zip Zip" id = "zip">Zip Zip</option>
<option value = "Sneakster" id = "sneak">Sneakster</option>
<option value = "Dolphin Dasher" id = "dphin">Dolphin Dasher</option>
<optgroup label = "Heavy Weight">
<option value = "Standard Kart L" id = "skl">Standard Kart L</option>
<option value = "Offroader" id = "offrdr">Offroader</option>
<option value = "Flame Flyer" id = "ffly">Flame Flyer</option>
<option value = "Pirahna Prowler" id = "prwlr">Pirahna Prowler</option>
<option value = "Jetsetter" id = "jetstr">Jetsetter</option>
<option value = "Honeycoupe" id = "hnycp">Honeycoupe</option>
<option value = "Standard Bike L" id = "sbl">Standard Bike L</option>
<option value = "Flame Runner" id = "frner">Flame Runner</option>
<option value = "Wario Bike" id = "wrobike">Wario Bike</option>
<option value = "Shooting Star" id = "shstr">Shooting Star</option>
<option value = "Spear" id = "spear">Spear</option>
<option value = "Phantom" id = "phntm">Phantom</option>
</select><br><br>
Vehichle Used For Secondary Character: <select id = "favKart2">
<optgroup label = "Light Weight">
<option value = "Standard Kart S" id = "sks">Standard Kart S</option>
<option value = "Booster Seat" id = "bseat">Booster Seat</option>
<option value = "Mini Beast" id = "mb">Mini Beast</option>
<option value = "Cheap Charger" id = "cc">Cheap Charger</option>
<option value = "Tiny Titan" id = "tt">Tiny Titan</option>
<option value = "Blue Falcon" id = "bf">Blue Falcon</option>
<option value = "Standard Bike S" id = "sbs">Standard Bike S</option>
<option value = "Bullet Bike" id = "bb">Bullet Bike</option>
<option value = "Bit Bike" id = "bitb">Bit Bike</option>
<option value = "Quacker" id = "qkr">Quacker</option>
<option value = "Magikruser" id = "mgcCrsr">Magikruser</option>
<option value = "Jet Bubble" id = "jb">Jet Bubble</option>
<optgroup label = "Medium Weight">
<option value = "Standard Kart M" id = "skm">Standard Kart M</option>
<option value = "Classic Dragster" id = "cd">Classic Dragster</option>
<option value = "Wild Wing" id = "ww">Wild Wing</option>
<option value = "Super Blooper" id = "sb">Super Blooper</option>
<option value = "Daytripper" id = "dtrp">Daytripper</option>
<option value = "Sprinter" id = "sprnt">Sprinter</option>
<option value = "Standard Bike M" id = "sbm">Standard Bike M</option>
<option value = "Mach Bike" id = "machb">Mach Bike</option>
<option value = "Sugarscoot" id = "sugar">Sugarscoot</option>
<option value = "Zip Zip" id = "zip">Zip Zip</option>
<option value = "Sneakster" id = "sneak">Sneakster</option>
<option value = "Dolphin Dasher" id = "dphin">Dolphin Dasher</option>
<optgroup label = "Heavy Weight">
<option value = "Standard Kart L" id = "skl">Standard Kart L</option>
<option value = "Offroader" id = "offrdr">Offroader</option>
<option value = "Flame Flyer" id = "ffly">Flame Flyer</option>
<option value = "Pirahna Prowler" id = "prwlr">Pirahna Prowler</option>
<option value = "Jetsetter" id = "jetstr">Jetsetter</option>
<option value = "Honeycoupe" id = "hnycp">Honeycoupe</option>
<option value = "Standard Bike L" id = "sbl">Standard Bike L</option>
<option value = "Flame Runner" id = "frner">Flame Runner</option>
<option value = "Wario Bike" id = "wrobike">Wario Bike</option>
<option value = "Shooting Star" id = "shstr">Shooting Star</option>
<option value = "Spear" id = "spear">Spear</option>
<option value = "Phantom" id = "phntm">Phantom</option>
</select><br><br>
License Color: <input id = "bgrnd" value = "#FFFFFF" type = "color"><br><br>
Text Color: <input id = "textClr" value = "#000000" type = "color"><br><br>
<input type = "button" name = "create" id = "create" value = "Create License">
<input type = "hidden" name = "image" id = "image" value = "">
<input type = "submit" value = "Share to Facebook" onclick = "<?PHP share(); ?>" id = "share">
</fieldset>
</form><br>
<p id = "canvasP">
Right click the image and click "Save image as..." to download license.<br>
<div class = "fb-share-button" data-href = "http://www.gigaboywebdesigns.com/mkwii-license/index.php" data-layout = "button_count"></div>
<sub>
<a href = "https://twitter.com/share" class = "twitter-share-button" data-url = "http://www.gigaboywebdesigns.com/mkwii-license/index.php">Tweet</a>
<script type = "text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<div class = "g-plus" data-action = "share" data-annotation = "bubble" data-href = "http://www.gigaboywebdesigns.com/mkwii-license/index.php"></div>
</sub><br>
<a href = "mk8.php" title = "Mario Kart 8 License Maker">
MK8 License Maker
</a>
<a href = "ssbb.php" title = "Super Smash Bros Brawl License Maker">
SSBB License Maker
</a><br>
<a href = "smk.php" title = "Super Mario Kart License Maker">
SMK License Maker
</a>
<a href = "mk64.php" title = "Mario Kart 64 License Maker">
MK64 License Maker
</a><br>
<a href = "mk7.php" title = "Mario Kart 7 License Maker">
MK7 License Maker
</a>
</p>
<canvas width = "530" height = "300" id = "mainCanvas"></canvas>
</div>
<img src = "images/yoshi.png" id = "yoshi" class = "img">
<img src = "images/baby_mario.png" id = "baby_mario" class = "img">
<img src = "images/baby_luigi.png" id = "baby_luigi" class = "img">
<img src = "images/baby_daisy.png" id = "baby_daisy" class = "img">
<img src = "images/baby_peach.png" id = "baby_peach" class = "img">
<img src = "images/toad.png" id = "toad" class = "img">
<img src = "images/toadette.png" id = "toadette" class = "img">
<img src = "images/dry_bones.png" id = "dry_bones" class = "img">
<img src = "images/koopa_troopa.png" id = "koopa_troopa" class = "img">
<img src = "images/mario.png" id = "mario" class = "img">
<img src = "images/luigi.png" id = "luigi" class = "img">
<img src = "images/peach.png" id = "peach" class = "img">
<img src = "images/daisy.png" id = "daisy" class = "img">
<img src = "images/birdo.png" id = "birdo" class = "img">
<img src = "images/diddy.png" id = "diddy" class = "img">
<img src = "images/bowser_jr.png" id = "bowser_jr" class = "img">
<img src = "images/wario.png" id = "wario" class = "img">
<img src = "images/bowser.png" id = "bowser" class = "img">
<img src = "images/waluigi.png" id = "waluigi" class = "img">
<img src = "images/dk.png" id = "dk" class = "img">
<img src = "images/boo.png" id = "boo" class = "img">
<img src = "images/dry_bowser.png" id = "dry_bowser" class = "img">
<img src = "images/rosalina.png" id = "rosalina" class = "img">
<img src = "images/funky.png" id = "funky" class = "img">
<img src = "images/mii.jpg" id = "mii" class = "img">
</section>

<footer>

</footer>
</body>
</HTML>

禁止

您无权访问此服务器上的/mkwii-license/。

此外,在尝试使用 ErrorDocument 处理请求时遇到了 403 Forbidden 错误。

最佳答案

您正在上传文件,并且可能没有访问上传文件保存位置的权限,即 PHP 没有访问该位置的权限。如果您将上传文件夹的权限设置为 777,那么它应该可以工作。您可以使用此命令更新权限:

chmod -r 777 /upload_folder_location/

您可以使用此命令检查当前权限:

ls -al

关于javascript - 为什么我被 403 禁止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35587968/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com