Upload php error: No such file or directory

Discuss coding issues, and scripts related to PHP and MySQL.
User avatar
JanMolendijk
Posts: 199
Location: Holland Rotterdam

Upload php error: No such file or directory

Well here i`m again... I wanna use this script
https://coursesweb.net/php-mysql/simple- ... -script_s2

Now i try with an id (int) into this script

Code: Select all

<?php
include('connection.php');

$id = (int) $_GET['id'];

$sql=mysqli_query($conn,"SELECT * FROM `user` WHERE id='" . $id . "' ");
$users=mysqli_fetch_assoc($sql);
?>
Now i try into your code this

Code: Select all

$uploadpath = 'images/$users[email]/';      // directory to store the uploaded files
$max_size = 2000;          // maximum file size, in KiloBytes
$alwidth = 1900;            // maximum allowed width, in pixels
$alheight = 1800;           // maximum allowed height, in pixels
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png');        // allowed extensions
I getting errors when i use $users[email]

Code: Select all

No such file or directory
I tried also with

Code: Select all

<?php echo $users[email];?>
but still getting the same error

Admin
Hello,
Try this code in the upload script:

Code: Select all

$uploadpath ='images/'. $users['email'] .'/'; // directory to store the uploaded files

//if the folder not exists, create it
if(!file_exists($uploadpath)){
  if(!mkdir($uploadpath, 0755)) echo 'Unable to create the folder: '. $uploadpath;
}
//the rest of your code..

JanMolendijk
I got one question i try to ad for the upload more extensions like avi or mp3
but when i put this i get the error

Code: Select all

The file: 03.avi not has the allowed extension type.

Code: Select all

$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png', 'avi');  
Is it posible with this script to ad more extensions ?

Edit:
- Sorry it workt just fine thanks for Suporting.

Similar Topics