标签:wordpress-plugin wordpress php image-uploading
我有一个正在使用的WordPress插件,似乎遇到了问题.
我需要用户能够上传图片,但我一直遇到这个问题:
上载目录不可写或不存在.
Warning:
move_uploaded_file(http://markpetherbridge.co.uk/ios/wp-content/plugins/rap/includes/productimages/78.105.162.431328735863.png)
[function.move-uploaded-file]: failed to open stream: HTTP wrapper
does not support writeable connections in
/home/markpeth/public_html/ios/wp-content/plugins/rap/includes/products.php
on line 39
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
move ‘/tmp/phpowqMlu’ to
‘http://markpetherbridge.co.uk/ios/wp-content/plugins/rap/includes/productimages/78.105.162.431328735863.png’
in
/home/markpeth/public_html/ios/wp-content/plugins/rap/includes/products.php
on line 39 There was an error uploading the file, please try again!
You have successfully added test_title to your products list
该目录绝对存在,我什至将CHMOD更改为777进行测试.
products.php文件如下所示:
<?
if ('POST' == $_SERVER['REQUEST_METHOD'])
{
global $wpdb;
$product_title = $_POST['title'];
$product_url = $_POST['url'];
$product_btn_text = $_POST['btn_text'];
// CREATE UNIQUE NAME FOR IMAGE
$remote_addr = $_SERVER['REMOTE_ADDR'];
$time = time();
$new_name = $remote_addr;
$new_name .= $time;
// IMAGE UPLOAD
$upload_dir = "http://markpetherbridge.co.uk/ios/wp-content/plugins/rap/includes/productimages/";
if (file_exists($upload_dir) && is_writable($upload_dir)) {
echo "<br /> Directory exists and is fine.... <br />";
}
else {
echo "Upload directory is not writable, or does not exist. <br />";
}
$uploadedfile = $_FILES['image_file']['name'];
$extension = explode(".", $uploadedfile);
$extensiontype = $extension['1'];
$target_path = $upload_dir;
$target_path = $target_path .$new_name .'.'.$extensiontype;
if(move_uploaded_file($_FILES['image_file']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['image_file']['name']).
" has been uploaded <br />";
} else{
echo "There was an error uploading the file, please try again! <br />";
}
$product_img = $new_name.'.'.$extensiontype;
//ADD TO DATABASE
$wpdb->query("INSERT INTO wp_rec_amazon_product (product_title, product_url, product_img, product_btn_text) VALUES ('$product_title', '$product_url','$product_img','$product_btn_text')");
echo "You have successfully added " .$product_title. " to your products list";
} else { ?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<table border="0" bordercolor="none" width="50%" cellpadding="0" cellspacing="0">
<tr>
<td>Product Title:</td>
<td><input type="text" name="title" value="product title" /></td>
</tr>
<tr>
<td>Product Url</td>
<td><input type="text" name="url" value="product url" /></td>
</tr>
<tr>
<td>Button text</td>
<td><input type="text" name="btn_text" value="Get your copy" /></td>
</tr>
</table>
<input type="file" name="image_file" />
<input type="submit" value="Submit" />
</form>
<?php }?>
信息被添加到数据库中,只是图像上传似乎不起作用.
有人知道吗?谢谢大家.
标签:wordpress-plugin,wordpress,php,image-uploading 来源: https://codeday.me/bug/20191101/1985674.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。