Hi !!
Below is my script. Basically is takes variables from a form....adds it to the database...adds photo file to the server, and attempts to create a thumbnail.
It works good...except when the file name contains spaces. The convert does not work if the file has spaces. How can I make the script work...even if spaces are in the file name?
Thanks!
<?
require('../connect.php');
$photoname = $_FILES[photo][name];
mysql_query("INSERT INTO inventory (
title,
inventory_no,
date,
dimensions,
materials,
price,
photo,
description
)
VALUES ('$title',
'$inventory_no',
'$date',
'$dimensions',
'$materials',
'$price',
'$photoname',
'$description'
)
");
/////Creates the image file and stores it in the $uploaddir directory
$img_tmp = $_FILES['photo']['tmp_name'];
//$img_location = "/httpd/customers/virtual/mydomain.com/htdocs/item_photos/$photoname";
$img_location = "/httpd/customers/virtual/mydomain.com/htdocs/item_photos/$photoname";
$uploaddir = '/httpd/customers/virtual/mydomain.com/htdocs/item_photos';
$uploadfile = $uploaddir . $_FILES['photo']['name'];
print "<pre>";
if
(move_uploaded_file($img_tmp, $img_location)) {
exec("convert -sample 200x239 /httpd/customers/virtual/mydomain.com/htdocs/item_photos/$photoname /httpd/customers/virtual/cmydomain.com/htdocs/item_photos/$photoname");
print
"
Your info has been accepted!<br>
This page will go back to the admin in 5 seconds.
<meta http-equiv='Refresh' content='5;url=index.php'>
";
passthru('
convert -sample 200x239 ../item_photos/$photoname ../item_photos/$photoname');
}
?>