I am having an issue. I created a form from where people can apply for jobs. I have 3 fields where I allow users to upload resume, references and other materials. This form works perfectly on my server which is linux based. When I uploaded it to a windows server, I get the following errors:
Warning: move_uploaded_file(./application/D:\Temp\php\php945C.tmp_tumblr.png) [function.move-uploaded-file]: failed to open stream: Invalid argument in D:\Hosting\9664396\html\application.php on line 23
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php945C.tmp' to './application/D:\Temp\php\php945C.tmp_tumblr.png' in D:\Hosting\9664396\html\application.php on line 23
Any help would be appreciated.
Here is the code:
if(isset($_FILES["photoToUpload"]['name'])){
$original_img_name = $_FILES["photoToUpload"]['name'];
} else {
$original_img_name = "";
}
$the_photo_url="None Uploaded";
if($original_img_name != ""){
$target = './application/';
$img_name = str_replace("&", "and", $original_img_name);
$img_name = preg_replace('/[^.a-zA-Z\d\s]+/s', '', $img_name);
$img_name = str_replace(' ', ' ', $img_name);
$img_name = str_replace(' ', '_', $img_name);
$img_name = str_replace("/", "", $_FILES["photoToUpload"]['tmp_name']) . "_" . $img_name;
move_uploaded_file($_FILES["photoToUpload"]['tmp_name'], $target . $img_name);
$the_photo_url = $target . $img_name;
}
This code is working perfect on my host which is linux based.
下一行是错误的,应在将tmp_name添加到$ img_name时将其删除。
$img_name = str_replace("/", "", $_FILES["photoToUpload"]['tmp_name']) . "_" . $img_name;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.