0

So my image gets uploaded without issues but what is this error I get after image gets uploaded on form submit?

Here is the error

This is the bit of my php:

if(isset($_POST['submit'])){

    if($_FILES['file']['name']!='')
    {
        $tmp_name = $_FILES["file"]["tmp_name"];
        $namefile = $_FILES["file"]["name"];
        $ext = end(explode(".", $namefile));   //line 16
        $fileUpload = move_uploaded_file($tmp_name,"blogUploads\images/".$image_name);   //line 17     
        $image_name=time().".".$ext;        
        watermark_image($tmp_name,"blogUploads\images/".$image_name);
        $img = ''.$image_name.'';
    }else{
        $img = '';
    }

}
1
  • $_FILES['file']['name']!='' is not the correct way to check for checking file instead you can use $_FILES['file']['error'] != 4'' also for using end you need to get the exploded result within variable and then need to use end($your_exploded_variable) Commented Dec 15, 2016 at 9:05

2 Answers 2

1

for error :"filename strict standards only variables should be passed by reference" in end(explode())

1st Assign the result of explode Array into a variable and then pass that variable to end like:

$tmp = explode('.', $namefile);
$file_extension = end($tmp);

or

$path_parts = pathinfo($filename);
$extension = $path_parts['extension'];
$fileName = $path_parts['filename'];

2nd for move_uploaded_file() error just ensure that destination path(2nd parameter) is valid (plus ensure that your upload folder has write permissions )

$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }

follow "Complete Upload File PHP Script" from
http://w3schools.com/php/php_file_upload.asp

PS:also assignment of $image_name variable should before move_uploaded_file()

Sign up to request clarification or add additional context in comments.

3 Comments

still not getting it mate could you show me on my cose? would really appreciate it
@sms247 one error disappeared now the move_uploaded_file() is reamining
follow "Complete Upload File PHP Script" from w3schools.com/php/php_file_upload.asp
1

Correct your directory structure on line 17 by this :

$fileUpload = move_uploaded_file($tmp_name,"blogUploads\images\".$image_name);;   //line 17     

and here also

watermark_image($tmp_name,"blogUploads\images\".$image_name);

6 Comments

can you explain what you face because it is the correct syntax for directory.
now the only error i face is in this like $fileUpload = move_uploaded_file($tmp_name,"blogUploads/images/".$image_name);
( ! ) Warning: move_uploaded_file(): Unable to move 'C:\wamp\tmp\phpC185.tmp' to 'blogUploads/images/' in C:\wamp\www\jobs\post-article.php on line 18
( ! ) Warning: move_uploaded_file(): The second argument to copy() function cannot be a directory in C:\wamp\www\jobs\post-article.php on line 18
provide your complete directory structure for upload image like this : $fileUpload = move_uploaded_file($tmp_name,"C:\wamp\www\jobs\blogUploads\images\".$image_name);; //line 17
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.