|
I am using magento community 1.7.0.2, and I am having problems getting this to work.
I am wanting to allow customers to upload images to my server.
I have tried just about everything I can find out there.
*************************my html file*****************************
<?xml version="1.0"
?>
<html>
<head>
<title></title>
<style>
table
{background:#0000;color:#3399cc;}
td{padding:20px;}
.align_center{text-align:center;}
.w125{width:125px;padding-top:0px;padding-bottom:0px;}
.red{color:#ff0000;font-size:20px;font-weight:bold;}
.blue{color:#3399cc;font-size:20px;font-weight:bold;padding:5px;}
.pl{padding-left:15px;padding-top:5px;padding-bottom:5px;}
.Header_catalog {font-family: ar BONNIE;}
.align_center form h1 .Header_catalog strong {color: #FF80FF;}
</style>
</head>
<body>
<table border="1">
<tr>
<td class="align_center" colspan="5">
<form action="single_upload.php" method="post" enctype="multipart/form-data"
name="upload[]" id="upload">
<h1>
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
<span class="Header_catalog"><strong>Upload Here</strong></span><strong>:</strong></h1>
<p>
<input name="userfile[0]" type="file" id="userfile[]" />
<input name="userfile[1]" type="file" id="userfile[]" />
<input name="userfile[2]" type="file" id="userfile[]" />
<input name="userfile[3]" type="file" id="userfile[]" />
<input name="userfile[4]" type="file" id="userfile[]" />
<input name="userfile[5]" type="file" id="userfile[]" />
<input name="userfile[6]" type="file" id="userfile[]" />
<input name="userfile[7]" type="file" id="userfile[]" />
<input name="userfile[8]" type="file" id="userfile[]" />
<input name="userfile[9]" type="file" id="userfile[]" />
</p>
<p>
<input type="submit" name="submit" value="Upload File(s)” />
</p>
</form>
</td>
</tr>
</table>
encoding="utf-8"?>
*********************************my php file (single_upload.php [i know this code is for multiple image upload])*******************************
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8” />
<title>Untitled Document</title>
</head>
<body>
<?php
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["/prestonphotoboost.com/tmp_folder"] . "<br>";
if (file_exists("/prestonphotoboost.com/upload" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["/prestonphotoboost.com/tmp_folder"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "/prestonphotoboost.com/upload" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
*******************************************************************************************
I suppose I’m not sure how to implement this code i.e., through magento admin- tried, didn’t work. Through ftp, tried, didn’t work.
I really at my wits end, and I’m hoping there is a simple solution.
Thanks to all that help-
Jonathan
|