Jump to content

Help with an Error


kyleldi

Recommended Posts

I keep getting an error when I try to execute my upload script, does anyone see what i've got wrong?  It's supposed to pull the $name field and create a folder (using _ instead of spaces), and then copy those files into that folder and replace those spaces w/ underscores as well.

 

Error: Warning: copy(files/Customer_Name/keyboard.jpg) [function.copy]: failed to open stream: No such file or directory in submitquote.php on line 60

 

else{

$dirname = str_replace(" ","_",$name);
if(!file_exists($dirname)) mkdir($dirname, 0755);

$image_list[14] = str_replace(" ","_",$image_list[14]);


$image_part = date("")."".$HTTP_POST_FILES['file01']['name'];
$image_list[14] = $image_part;
copy($HTTP_POST_FILES['file01']['tmp_name'], "files/$dirname/".$image_part);
// the above line is line 60 //
$image_part = date("")."".$HTTP_POST_FILES['file02']['name'];
$image_list[15] = $image_part;
copy($HTTP_POST_FILES['file02']['tmp_name'], "files/$dirname/".$image_part);
$image_part = date("")."".$HTTP_POST_FILES['file03']['name'];
$image_list[16] = $image_part;
copy($HTTP_POST_FILES['file03']['tmp_name'], "files/$dirname/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));

Link to comment
https://forums.phpfreaks.com/topic/71819-help-with-an-error/
Share on other sites

are you sure you have the correct path to the file?

 

is "files" a folder within the directory that the script is running in?  or is it in the root of your website?

 

should it be copy("/files/Customer_Name/keyboard.jpg") ?

or perhaps the full path: copy("/var/html/home/some_other_directory/files/Customer_Name/keyboard.jpg") ?

 

I'd mess around with that first

Link to comment
https://forums.phpfreaks.com/topic/71819-help-with-an-error/#findComment-361707
Share on other sites

Not according to your OP.

 

It's supposed to pull the $name field and create a folder (using _ instead of spaces), and then copy those files into that folder and replace those spaces w/ underscores as well.

 

You seem to want to create folder X, then put a file in folder X.  What you're actually doing is creating folder X and trying to put a file in folder Y.  You need to change either one of the two lines of code I quoted above to fix the problem.

Link to comment
https://forums.phpfreaks.com/topic/71819-help-with-an-error/#findComment-361744
Share on other sites

Ok, I took care of the file path problem, but for some reason it still won't replace the spaces in each filename with underscores.  Here's my code to make it easier to understand... Thanks!

 

$file01 = str_replace(" ","_",$$file01);
$file02 = str_replace(" ","_",$$file02);
$file03 = str_replace(" ","_",$$file03);
if($HTTP_POST_FILES['file01']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['file01']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['file01']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['file02']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['file02']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['file02']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['file03']['tmp_name']==""){ }
else if(!is_uploaded_file($HTTP_POST_FILES['file03']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['file03']['name'].", was not uploaded!";
$errors=1;
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;


else{

$dirname = str_replace(" ","_",$name);
if(!file_exists($dirname)) mkdir($dirname, 0755);


$image_part = date("")."".$HTTP_POST_FILES['file01']['name'];
$image_list[14] = $image_part;
copy($HTTP_POST_FILES['file01']['tmp_name'], "$dirname/".$image_part);
$image_part = date("")."".$HTTP_POST_FILES['file02']['name'];
$image_list[15] = $image_part;
copy($HTTP_POST_FILES['file02']['tmp_name'], "$dirname/".$image_part);
$image_part = date("")."".$HTTP_POST_FILES['file03']['name'];
$image_list[16] = $image_part;
copy($HTTP_POST_FILES['file03']['tmp_name'], "$dirname/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));

Link to comment
https://forums.phpfreaks.com/topic/71819-help-with-an-error/#findComment-361768
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.