hi ,
I have a series of pages 1 has input forms that send variables to a page that uploads and submits the files and text to mysql . It works fine until someone tries to upload a file with white space in the name the problem im having is
in my submit page I cant place the str_replace function would someone be so kind as to help me to place this properly.
cheer
code below without db connection stuff
can someone plaese add this to it
str_replace(" ", "_", $file_image);
===============================================
<?
//grabs the variables
$title = $_POST["title"]; //brief title blurb
$image = $_POST["image"]; // anchor tag for image
$name = $_POST["name"]; // application name
$description = $_POST["description"]; // long description
$file_up = $HTTP_POST_FILES['file']['name']; // file app upload
#$file_source =$HTTP_POST_FILES['file_source']['name']; // file source upload
$file_image = $HTTP_POST_FILES['file_image']['name']; // screengrab image upload
$file_size = round($HTTP_POST_FILES['file']['size'] / 1024)."kbs"; // app file size kbs
#$source_size = round($HTTP_POST_FILES['file_source']['size'] / 1024)."kbs"; // source file size kbs
$kb = 1024; // Kilobyte
$mb = 1024 * $kb; // Megabyte
$gb = 1024 * $mb; // Gigabyte
$tb = 1024 * $gb; // Terabyte
if($file_size < $kb) {
$file_size." B";
}
else if($file_size < $mb) {
round($file_size/$kb,2)." KB";
}
else if($file_size < $gb) {
round($file_size/$mb,2)." MB";
}
else if($file_size < $tb) {
round($file_size/$gb,2)." GB";
}
else {
round($file_size/$tb,2)." TB";
}
$date = date("j F Y");
$addnews =MYSQL_QUERY("INSERT INTO tblZ_test (id,title,date,image,name,description,file_up,file_size,file_image)". "VALUES
('NULL', '$title', '$date', '$image','$name','$description','$file_up','$file_size','$file_image')");
//success...
{
//File has passed all validation, copy it to the final destination and remove the temporary file:
//copy application and upload
copy($HTTP_POST_FILES['file']['tmp_name'],"images/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
//copy source and upload
// copy($HTTP_POST_FILES['file_source']['tmp_name'],"images/".$HTTP_POST_FILES['file_source']['name']);
// unlink($HTTP_POST_FILES['file_source']['tmp_name']);
//copy image and upload
copy($HTTP_POST_FILES['file_image']['tmp_name'],"images/".$HTTP_POST_FILES['file_image']['name']);
unlink($HTTP_POST_FILES['file_image']['tmp_name']);
// print "File has been successfully uploaded!";
//exit;
}
//echo("Description Added!");
?>
=====================================================
thanks
I have a series of pages 1 has input forms that send variables to a page that uploads and submits the files and text to mysql . It works fine until someone tries to upload a file with white space in the name the problem im having is
in my submit page I cant place the str_replace function would someone be so kind as to help me to place this properly.
cheer
code below without db connection stuff
can someone plaese add this to it
str_replace(" ", "_", $file_image);
===============================================
<?
//grabs the variables
$title = $_POST["title"]; //brief title blurb
$image = $_POST["image"]; // anchor tag for image
$name = $_POST["name"]; // application name
$description = $_POST["description"]; // long description
$file_up = $HTTP_POST_FILES['file']['name']; // file app upload
#$file_source =$HTTP_POST_FILES['file_source']['name']; // file source upload
$file_image = $HTTP_POST_FILES['file_image']['name']; // screengrab image upload
$file_size = round($HTTP_POST_FILES['file']['size'] / 1024)."kbs"; // app file size kbs
#$source_size = round($HTTP_POST_FILES['file_source']['size'] / 1024)."kbs"; // source file size kbs
$kb = 1024; // Kilobyte
$mb = 1024 * $kb; // Megabyte
$gb = 1024 * $mb; // Gigabyte
$tb = 1024 * $gb; // Terabyte
if($file_size < $kb) {
$file_size." B";
}
else if($file_size < $mb) {
round($file_size/$kb,2)." KB";
}
else if($file_size < $gb) {
round($file_size/$mb,2)." MB";
}
else if($file_size < $tb) {
round($file_size/$gb,2)." GB";
}
else {
round($file_size/$tb,2)." TB";
}
$date = date("j F Y");
$addnews =MYSQL_QUERY("INSERT INTO tblZ_test (id,title,date,image,name,description,file_up,file_size,file_image)". "VALUES
('NULL', '$title', '$date', '$image','$name','$description','$file_up','$file_size','$file_image')");
//success...
{
//File has passed all validation, copy it to the final destination and remove the temporary file:
//copy application and upload
copy($HTTP_POST_FILES['file']['tmp_name'],"images/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
//copy source and upload
// copy($HTTP_POST_FILES['file_source']['tmp_name'],"images/".$HTTP_POST_FILES['file_source']['name']);
// unlink($HTTP_POST_FILES['file_source']['tmp_name']);
//copy image and upload
copy($HTTP_POST_FILES['file_image']['tmp_name'],"images/".$HTTP_POST_FILES['file_image']['name']);
unlink($HTTP_POST_FILES['file_image']['tmp_name']);
// print "File has been successfully uploaded!";
//exit;
}
//echo("Description Added!");
?>
=====================================================
thanks