Jump to content

Recommended Posts

Hope someone can help with this - it's some code I've used before, and had working fine, but am having problems with another site.

 

In the site it works for, I have a file input :

 

<tr>
<td class="labelcell">Image File Name </td>
<td class="fieldcell"><input type="file" name="Image"></td>
</tr>

 

And then in a validate.php page, the upload code :

 

if ( is_uploaded_file($_FILES['Image']['tmp_name']) ) {

$destpath = '../Photos/' . basename($_FILES['Image']['name']);

if (!move_uploaded_file($_FILES['Image']['tmp_name'], $destpath) ) {
  echo 'Error moving file ' . $_FILES['Image']['tmp_name'] . ' to ' . $destpath;
}
}

 

Which, as I say, works fine.

 

However, in a new site I'm doing, I have the input as :

 

<tr>
<td class="labelcell">Image File Name </td>
<td class="fieldcell"><input type="file" name="ImageLarge"></td>
</tr

>

 

And the upload code in my validation file :

 

if ( is_uploaded_file($_FILES['ImageLarge']['tmp_name']) ) {

$destpath = '../jewelleryimages/' . basename($_FILES['ImageLarge']['name']);

if (!move_uploaded_file($_FILES['ImageLarge']['tmp_name'], $destpath) ) {
  echo 'Error moving file ' . $_FILES['ImageLarge']['tmp_name'] . ' to ' . $destpath;
}
}

 

ie, ie matching the input field name, 'ImageLarge', and changing the destination path (double checked) to '../jewelleryimages/'

 

However, when I try to use it, I'm getting the error :

 

Warning: move_uploaded_file(../jewelleryimages/fashion.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/iqzwlvrk/public_html/admin/validate3.php on line 243

 

Where line 243 is

 

if (!move_uploaded_file($_FILES['ImageLarge']['tmp_name'], $destpath) ) {

 

Any idea what I'm missing here?

 

Many thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/69455-solved-upload-file-script/
Share on other sites

Think I've found it - comparing the permissions in the respective control panels, the original is set to 0777, while the new one is still showing as 0755 - changed that, and it's fine.

 

Think I had a mental block about permissions to access the database.

 

Cheers.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.