I'm trying to upload both a .jpg file and a .pdf file in the same process, but i get the following error:
path: /tmp/phpjSmIVE
name: 04030900.JPG
size: 10089 bytes
type: image/pjpeg
path: none
name: h995_25art_f002_250_1000.pdf
size: 0 bytes
type: application/pdf
Warning: Unable to open 'none' for reading: No such file or directory in /domains/305/590/html/update_av.php on line 25
Could not copy none to server (details).
This is the code:
<?php
$file_dir = "/users/hexell/domains/hexellwylie.com/html";
$file_url = "http://hexelwylie.com";
$rent = number_format($rent, 2);
$rates = number_format($rates, 2);
$service = number_format($service, 2);
print "path: $photo<br>\n";
print "name: $photo_name<br>\n";
print "size: $photo_size bytes<br>\n";
print "type: $photo_type<p>\n\n";
print "path: $details<br>\n";
print "name: $details_name<br>\n";
print "size: $details_size bytes<br>\n";
print "type: $details_type<p>\n\n";
if ( $photo_type == "image/pjpeg" && $MAX_FILE_SIZE <= "51200" && $details_type == "application/pdf" )
{
$db = "property";
$link = mysql_connect( "localhost:/users/hexell/domains/hexellwylie.com/sql/mysql.sock", "root" );
if ( !$link ) die( "Couldn't connect to MySQL".mysql_error() );
mysql_select_db( $db, $link ) or die( "Couldn't open $db: ".mysql_error() );
$sql = "INSERT INTO av VALUES ( '', now(), '$address', '$photo_name', '$postcode', '$floor', '$areasf', '$rent', '$rates', '$service', '$spec_1', '$spec_2', '$spec_3', '$spec_4', '$spec_5', '$spec_6', '$spec_7', '$spec_8', '$spec_9', '$spec_10', '$spec_11', '$spec_12', '$spec_13', '$spec_14', '$email', '$details_name' )";
mysql_query( $sql, $link );
mysql_close( $link );
copy ( $photo, "$file_dir/photos/$photo_name" ) or die ("Could not copy $photo to server (photos).");
copy ( $details, "$file_dir/details/$details_name" ) or die ("Could not copy $details to server (details).");
}
elseif ( $photo_size == "0" || !isset( $details ) )
{
$db = "property";
$link = mysql_connect( "localhost:/users/hexell/domains/hexellwylie.com/sql/mysql.sock", "root" );
if ( !$link ) die( "Couldn't connect to MySQL".mysql_error() );
mysql_select_db( $db, $link ) or die( "Couldn't open $db: ".mysql_error() );
$photo_name = "No image uploaded - sorry!";
$details_name = "No details uploaded - sorry!";
$sql = "INSERT INTO av VALUES ( '', now(), '$address', '$photo_name', '$postcode', '$floor', '$areasf', '$rent', '$rates', '$service', '$spec_1', '$spec_2', '$spec_3', '$spec_4', '$spec_5', '$spec_6', '$spec_7', '$spec_8', '$spec_9', '$spec_10', '$spec_11', '$spec_12', '$spec_13', '$spec_14', '$email', '$details_name' )";
mysql_query( $sql, $link );
mysql_close( $link );
}
else
{
if ( $MAX_FILE_SIZE > "51200" ){
print "File size beyond maximum size of 51,200 bytes - ($photo_size bytes)";
exit;
}
elseif ( $photo_type != "image/pjpeg" ){
print "Invalid file type $photo_type. Please submit only pjepg images (with extensions .jpg / .jpeg)";
exit;
}
else
{
print "Failed - reason unknown.";
exit;
}
}
?>
Any ideas / help much appreciated!!!