我有一個WordPress插件在我的工作,我似乎已經打了一個問題。 我需要用戶能夠上傳圖像,而不是我一直得到這個問題:PHP圖片上傳(WordPress的自定義插件)
上傳目錄不可寫或不存在。
警告: move_uploaded_file(http://markpetherbridge.co.uk/ios/wp-content/plugins/rap/includes/productimages/78.105.162.431328735863.png) [function.move上傳文件]:未能打開流:HTTP包裝 不在線支持 /home/markpeth/public_html/ios/wp-content/plugins/rap/includes/products.php 可寫連接39
警告:move_uploaded_file()以[function.move上傳文件]:無法 移動 '/ TMP/phpowqMlu' 至 「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在線39上的 上傳文件時出現錯誤,請重試! 您已成功將test_title到你的產品列表
目錄肯定是存在的,我甚至改變了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 }?>
的信息被添加到DATABSE,它只是將圖片上傳似乎並不奏效。
有沒有人有任何想法?謝謝大家。 :)
對不起,我用這個:/ home/markpeth/public_html/ios/wp-content/plugins/rap/includes /它工作 – Danienllxxox 2012-02-08 21:38:48
你提到我的名字但是不投票給我:-(我現在很傷心! – thenetimp 2012-02-08 21:42:07